Skip to content

Commit 3743cb0

Browse files
Fix popups drag issue when selecting input values (#67)
When trying to select input values (by dragging the cursor) inside list and timing popup, the popup cdkDrag will be disabled, ensuring that the select event does not cause dragging of the popup.
1 parent ff7abdc commit 3743cb0

File tree

4 files changed

+62
-2
lines changed

4 files changed

+62
-2
lines changed

script-gen-ui/src/app/components/main-sweep/list/list.component.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div #listPopUp class="sweep-list-popup" cdkDrag cdkDragBoundary="body">
1+
<div #listPopUp class="sweep-list-popup" cdkDrag cdkDragBoundary="body" [cdkDragDisabled]="isDragDisabled">
22
<div class="sweep-list-popup-content">
33
<div class="sweep-list-popup-header" cdkDragHandle>
44
<h3 style="margin: 0">List</h3>
@@ -14,6 +14,9 @@ <h3 style="margin: 0">List</h3>
1414
*ngIf="noOfPointsOrSteps !== undefined && noOfPointsOrSteps !== null"
1515
(inputChange)="emitStepsOrPoints()"
1616
[disabled]="!isNoOfPointsOrSteps"
17+
(mousedown)="onInputMouseDown()"
18+
(mouseup)="onInputMouseUp()"
19+
(blur)="onInputBlur()"
1720
></app-input-numeric>
1821
</div>
1922
<div class="sweep-list-popup-inputs">
@@ -42,6 +45,9 @@ <h3 style="margin: 0">List</h3>
4245
(inputChange)="onChange()"
4346
style="width: 95%"
4447
[disabled]="!sweep.isDeviceValid"
48+
(mousedown)="onInputMouseDown()"
49+
(mouseup)="onInputMouseUp()"
50+
(blur)="onInputBlur()"
4551
></app-input-plain>
4652
</td>
4753
</tr>

script-gen-ui/src/app/components/main-sweep/list/list.component.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export class ListComponent implements OnChanges, AfterViewInit {
4949
@Output() updatedStepsOrPoints = new EventEmitter<number>();
5050

5151
rowIndices: number[] = [];
52+
isDragDisabled = false;
5253

5354
getRowIndices(): number[] {
5455
return this.listsWithNames.length > 0
@@ -97,4 +98,22 @@ export class ListComponent implements OnChanges, AfterViewInit {
9798
this.listPositionChange.emit({ left: rect.left, top: rect.top });
9899
}
99100
}
101+
102+
onInputBlur() {
103+
this.isDragDisabled = false;
104+
}
105+
106+
onInputMouseDown() {
107+
this.isDragDisabled = true;
108+
109+
setTimeout(() => {
110+
if (this.isDragDisabled) {
111+
this.isDragDisabled = false;
112+
}
113+
}, 500);
114+
}
115+
116+
onInputMouseUp() {
117+
this.isDragDisabled = false;
118+
}
100119
}

script-gen-ui/src/app/components/main-sweep/timing/timing.component.html

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="popup">
2-
<div class="popup-content" cdkDrag cdkDragBoundary="body">
2+
<div class="popup-content" cdkDrag cdkDragBoundary="body" [cdkDragDisabled]="isDragDisabled">
33
<!-- <span class="close" (click)="close_Timing()">&times;</span> -->
44
<div>
55
<div class="popup-header" cdkDragHandle>
@@ -16,6 +16,9 @@ <h3 id="timingLabel">Timing</h3>
1616
[label]="'Measure Count (per step)'"
1717
*ngIf="measureCount"
1818
(inputChange)="submitTimingData()"
19+
(mousedown)="onInputMouseDown()"
20+
(mouseup)="onInputMouseUp()"
21+
(blur)="onInputBlur()"
1922
></app-input-numeric>
2023
</div>
2124

@@ -42,6 +45,9 @@ <h3 id="SMUTimingLabel">SMU Timing</h3>
4245
[label]="'NPLC'"
4346
*ngIf="nplc"
4447
(inputChange)="submitTimingData()"
48+
(mousedown)="onInputMouseDown()"
49+
(mouseup)="onInputMouseUp()"
50+
(blur)="onInputBlur()"
4551
></app-input-numeric>
4652
</div>
4753
<div *ngIf="nplcType?.value === 'Aperture'">
@@ -52,6 +58,9 @@ <h3 id="SMUTimingLabel">SMU Timing</h3>
5258
[unit]="aperture.unit"
5359
*ngIf="aperture"
5460
(inputChange)="submitTimingData()"
61+
(mousedown)="onInputMouseDown()"
62+
(mouseup)="onInputMouseUp()"
63+
(blur)="onInputBlur()"
5564
></app-input-plain>
5665
</div>
5766
<div>
@@ -73,6 +82,9 @@ <h3 id="SMUTimingLabel">SMU Timing</h3>
7382
[unit]="sourceDelay.unit"
7483
*ngIf="sourceDelay"
7584
(inputChange)="submitTimingData()"
85+
(mousedown)="onInputMouseDown()"
86+
(mouseup)="onInputMouseUp()"
87+
(blur)="onInputBlur()"
7688
></app-input-plain>
7789
</div>
7890
<div>
@@ -94,6 +106,9 @@ <h3 id="SMUTimingLabel">SMU Timing</h3>
94106
[unit]="measureDelay.unit"
95107
*ngIf="measureDelay"
96108
(inputChange)="submitTimingData()"
109+
(mousedown)="onInputMouseDown()"
110+
(mouseup)="onInputMouseUp()"
111+
(blur)="onInputBlur()"
97112
></app-input-plain>
98113
</div>
99114
</div>

script-gen-ui/src/app/components/main-sweep/timing/timing.component.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export class TimingComponent implements OnDestroy, OnChanges {
6161

6262
boundaryElement = 'app-root';
6363

64+
isDragDisabled = false;
65+
6466
@Input() sweepTimingConfig: SweepTimingConfig | undefined;
6567
@Output() ok = new EventEmitter<void>();
6668
@Output() emitTimingData = new EventEmitter<void>();
@@ -129,6 +131,24 @@ export class TimingComponent implements OnDestroy, OnChanges {
129131
});
130132
}
131133

134+
onInputBlur() {
135+
this.isDragDisabled = false;
136+
}
137+
138+
onInputMouseDown() {
139+
this.isDragDisabled = true;
140+
141+
setTimeout(() => {
142+
if (this.isDragDisabled) {
143+
this.isDragDisabled = false;
144+
}
145+
}, 500);
146+
}
147+
148+
onInputMouseUp() {
149+
this.isDragDisabled = false;
150+
}
151+
132152
ngOnDestroy(): void {
133153
console.log('component destroyed');
134154
}

0 commit comments

Comments
 (0)