Skip to content

Commit 6646541

Browse files
jackfranklinDevtools-frontend LUCI CQ
authored andcommitted
RPP: ensure labels being edited get drawn above others
Which makes it easier to edit them in the event that other labels are overlapping. Fixed: 406938980 Change-Id: I30f7d7232ac2ecc3e9f5a213f007bd53cf0bef3f Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6415908 Auto-Submit: Jack Franklin <[email protected]> Commit-Queue: Alina Varkki <[email protected]> Reviewed-by: Alina Varkki <[email protected]>
1 parent f53ea2f commit 6646541

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

front_end/panels/timeline/overlays/OverlaysImpl.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,20 +787,22 @@ describeWithEnvironment('Overlays', () => {
787787
assert.isNotOk(aiLabelButtonWrapper);
788788
});
789789

790-
it('Inputting `Enter`into label overlay makes it non-editable', async function() {
791-
const {inputField} = await createAnnotationsLabelElement(this, 'web-dev.json.gz', 50, 'label');
790+
it('Inputting `Enter` into label overlay makes it non-editable', async function() {
791+
const {inputField, component} = await createAnnotationsLabelElement(this, 'web-dev.json.gz', 50, 'label');
792792

793793
// Double click on the label box to make it editable and focus on it
794794
inputField.dispatchEvent(new FocusEvent('dblclick', {bubbles: true}));
795795

796796
// Ensure the label content is editable
797797
assert.isTrue(inputField.isContentEditable);
798+
assert.isTrue(component.hasAttribute('data-user-editing-label'));
798799

799800
// Press `Enter` to make the label not editable
800801
inputField.dispatchEvent(new KeyboardEvent('keydown', {key: 'Enter', cancelable: true, bubbles: true}));
801802

802803
// Ensure the label content is not editable
803804
assert.isFalse(inputField.isContentEditable);
805+
assert.isFalse(component.hasAttribute('data-user-editing-label'));
804806
});
805807

806808
it('Inputting `Enter` into time range label field when the label is empty removes the overlay', async function() {

front_end/panels/timeline/overlays/components/EntryLabelOverlay.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,15 @@ export class EntryLabelOverlay extends HTMLElement {
461461
if (this.#inAIConsentDialogFlow && editable === false) {
462462
return;
463463
}
464+
465+
// Set an attribute on the host; this is used in the overlays CSS to bring
466+
// the focused, editable label to the top above any others.
467+
if (editable) {
468+
this.setAttribute('data-user-editing-label', 'true');
469+
} else {
470+
this.removeAttribute('data-user-editing-label');
471+
}
472+
464473
this.#isLabelEditable = editable;
465474
this.#render();
466475
// If the label is editable, focus cursor on it & put the cursor at the end

front_end/panels/timeline/timelineFlameChartView.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@
2222
.overlay-type-ENTRY_LABEL {
2323
/* keep these above the selected entry overline, else they can become hard to read */
2424
z-index: 2;
25+
26+
/* if an overlay is being edited, keep it above the rest so the user is not obstructed */
27+
&:has([data-user-editing-label]) {
28+
z-index: 3;
29+
}
2530
}
2631

32+
2733
.overlay-type-ENTRY_SELECTED,
2834
.overlay-type-ENTRY_OUTLINE {
2935
pointer-events: none;

0 commit comments

Comments
 (0)