Skip to content

Commit f66dcfb

Browse files
Alexander PavlovDevtools-frontend LUCI CQ
Alexander Pavlov
authored and
Devtools-frontend LUCI CQ
committed
DevTools: Close picker for contrast background color on Esc
Also disable the bg color picker button upon selection. Bug: 40140133 Change-Id: I49858d36717bdcf0b7556577f9109cc3b708328b Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6444747 Reviewed-by: Alex Rudenko <alexrudenko@chromium.org> Reviewed-by: Danil Somsikov <dsv@chromium.org> Commit-Queue: Alexander Pavlov <apavlov@chromium.org>
1 parent adbf0df commit f66dcfb

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

front_end/ui/legacy/components/color_picker/ContrastDetails.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ export class ContrastDetails extends Common.ObjectWrapper.ObjectWrapper<EventTyp
465465
const color = Common.Color.Legacy.fromRGBA(rgba);
466466
this.contrastInfo.setBgColor(color);
467467
this.toggleBackgroundColorPickerInternal(false);
468+
this.bgColorPickerButton.toggled(false);
468469
Host.InspectorFrontendHost.InspectorFrontendHostInstance.bringToFront();
469470
}
470471
}

front_end/ui/legacy/components/color_picker/Spectrum.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ export class Spectrum extends Common.ObjectWrapper.eventMixin<EventTypes, typeof
229229
private srgbOverlay: SrgbOverlay.SrgbOverlay.SrgbOverlay;
230230
private contrastOverlay: ContrastOverlay|undefined;
231231
private contrastDetails: ContrastDetails|undefined;
232-
private readonly contrastDetailsBackgroundColorPickedToggledBound:
232+
private readonly contrastDetailsBackgroundColorPickerToggledBound:
233233
((event: Common.EventTarget.EventTargetEvent<boolean>) => void)|undefined;
234234
private readonly palettes: Map<string, Palette>;
235235
private readonly palettePanel: HTMLElement;
@@ -399,8 +399,8 @@ export class Spectrum extends Common.ObjectWrapper.eventMixin<EventTypes, typeof
399399
this.contrastInfo, this.contentElement, this.toggleColorPicker.bind(this),
400400
this.contrastPanelExpandedChanged.bind(this), this.colorSelected.bind(this));
401401

402-
this.contrastDetailsBackgroundColorPickedToggledBound =
403-
this.contrastDetailsBackgroundColorPickedToggled.bind(this);
402+
this.contrastDetailsBackgroundColorPickerToggledBound =
403+
this.contrastDetailsBackgroundColorPickerToggled.bind(this);
404404
}
405405

406406
this.element.classList.add('flex-none');
@@ -572,7 +572,7 @@ export class Spectrum extends Common.ObjectWrapper.eventMixin<EventTypes, typeof
572572
return true;
573573
}
574574

575-
private contrastDetailsBackgroundColorPickedToggled(event: {
575+
private contrastDetailsBackgroundColorPickerToggled(event: {
576576
data: unknown,
577577
}): void {
578578
if (event.data) {
@@ -1355,19 +1355,19 @@ export class Spectrum extends Common.ObjectWrapper.eventMixin<EventTypes, typeof
13551355
this.colorPickerButton.setToggled(false);
13561356
}
13571357

1358-
if (this.contrastDetails && this.contrastDetailsBackgroundColorPickedToggledBound) {
1358+
if (this.contrastDetails && this.contrastDetailsBackgroundColorPickerToggledBound) {
13591359
this.contrastDetails.addEventListener(
13601360
ContrastDetailsEvents.BACKGROUND_COLOR_PICKER_WILL_BE_TOGGLED,
1361-
this.contrastDetailsBackgroundColorPickedToggledBound);
1361+
this.contrastDetailsBackgroundColorPickerToggledBound);
13621362
}
13631363
}
13641364

13651365
override willHide(): void {
13661366
void this.toggleColorPicker(false);
1367-
if (this.contrastDetails && this.contrastDetailsBackgroundColorPickedToggledBound) {
1367+
if (this.contrastDetails && this.contrastDetailsBackgroundColorPickerToggledBound) {
13681368
this.contrastDetails.removeEventListener(
13691369
ContrastDetailsEvents.BACKGROUND_COLOR_PICKER_WILL_BE_TOGGLED,
1370-
this.contrastDetailsBackgroundColorPickedToggledBound);
1370+
this.contrastDetailsBackgroundColorPickerToggledBound);
13711371
}
13721372
}
13731373

@@ -1376,9 +1376,10 @@ export class Spectrum extends Common.ObjectWrapper.eventMixin<EventTypes, typeof
13761376
enabled = this.colorPickerButton.isToggled();
13771377
}
13781378

1379-
// This is to make sure that only one picker is open at a time
1380-
// Also have a look at this.contrastDetailsBackgroundColorPickedToggled
1381-
if (this.contrastDetails && enabled && this.contrastDetails.backgroundColorPickerEnabled()) {
1379+
// This is to make sure that only one picker is open at a time (enabled is true) and
1380+
// the background color picker gets dismissed whenever the popup is closed by an Esc (enabled is false).
1381+
// Also have a look at this.contrastDetailsBackgroundColorPickedToggled.
1382+
if (this.contrastDetails?.backgroundColorPickerEnabled()) {
13821383
this.contrastDetails.toggleBackgroundColorPicker(false);
13831384
}
13841385

0 commit comments

Comments
 (0)