Skip to content

Commit 3866be6

Browse files
committed
Stabilize LOINC order preview compact layout switching
1 parent 512671f commit 3866be6

2 files changed

Lines changed: 5 additions & 10 deletions

File tree

src/app/loinc/loinc-order/loinc-order.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="order-layout" #orderLayoutRoot [class.order-layout-compact]="hasMeasuredLayout && isCompactLayout">
2-
<section class="search-panel" #searchPanelRoot>
2+
<section class="search-panel">
33
<app-loinc-order-search-panel
44
[patient]="activePatient"
55
[showOrderPreviewButton]="hasMeasuredLayout && isCompactLayout"

src/app/loinc/loinc-order/loinc-order.component.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import type { LaboratoryOrderGroup, ServiceRequest } from 'src/app/model';
1313
standalone: false
1414
})
1515
export class LoincOrderComponent implements AfterViewInit, OnDestroy {
16-
private readonly compactLayoutBreakpoint = 1400;
1716
private readonly searchPanelMinWidth = 1100;
17+
private readonly searchPanelWidthRatio = 3 / 5;
18+
private readonly compactLayoutBreakpoint = Math.ceil(this.searchPanelMinWidth / this.searchPanelWidthRatio);
1819
private readonly visualViewportResizeHandler = () => this.updateCompactLayoutFromContainer();
1920

2021
@ViewChild('orderLayoutRoot') orderLayoutRoot?: ElementRef<HTMLElement>;
21-
@ViewChild('searchPanelRoot') searchPanelRoot?: ElementRef<HTMLElement>;
2222
@Input() patient: any = null;
2323
@Input() showSaveAction = false;
2424
@Output() orderSaved = new EventEmitter<LaboratoryOrderGroup>();
@@ -336,11 +336,7 @@ export class LoincOrderComponent implements AfterViewInit, OnDestroy {
336336
this.updateCompactLayoutFromContainer();
337337
}
338338

339-
private computeIsCompactLayout(containerWidth?: number, searchPanelWidth?: number): boolean {
340-
if (typeof searchPanelWidth === 'number' && searchPanelWidth > 0) {
341-
return searchPanelWidth <= this.searchPanelMinWidth;
342-
}
343-
339+
private computeIsCompactLayout(containerWidth?: number): boolean {
344340
if (typeof containerWidth === 'number' && containerWidth > 0) {
345341
return containerWidth <= this.compactLayoutBreakpoint;
346342
}
@@ -350,8 +346,7 @@ export class LoincOrderComponent implements AfterViewInit, OnDestroy {
350346

351347
private updateCompactLayoutFromContainer() {
352348
const containerWidth = this.orderLayoutRoot?.nativeElement.getBoundingClientRect().width;
353-
const searchPanelWidth = this.searchPanelRoot?.nativeElement.getBoundingClientRect().width;
354-
this.isCompactLayout = this.computeIsCompactLayout(containerWidth, searchPanelWidth);
349+
this.isCompactLayout = this.computeIsCompactLayout(containerWidth);
355350
this.hasMeasuredLayout = true;
356351
}
357352
}

0 commit comments

Comments
 (0)