Merge pull request #17534 from calixteman/bug1875357
[Editor] Change the arrow direction when the dropdown is visible in the color picker (bug 1875357)
This commit is contained in:
commit
a0e2b62245
@ -20,6 +20,8 @@ import { noContextMenu } from "../display_utils.js";
|
|||||||
class ColorPicker {
|
class ColorPicker {
|
||||||
#boundKeyDown = this.#keyDown.bind(this);
|
#boundKeyDown = this.#keyDown.bind(this);
|
||||||
|
|
||||||
|
#boundPointerDown = this.#pointerDown.bind(this);
|
||||||
|
|
||||||
#button = null;
|
#button = null;
|
||||||
|
|
||||||
#buttonSwatch = null;
|
#buttonSwatch = null;
|
||||||
@ -177,18 +179,25 @@ class ColorPicker {
|
|||||||
}
|
}
|
||||||
this.#button.addEventListener("keydown", this.#boundKeyDown);
|
this.#button.addEventListener("keydown", this.#boundKeyDown);
|
||||||
this.#dropdownWasFromKeyboard = event.detail === 0;
|
this.#dropdownWasFromKeyboard = event.detail === 0;
|
||||||
|
window.addEventListener("pointerdown", this.#boundPointerDown);
|
||||||
if (this.#dropdown) {
|
if (this.#dropdown) {
|
||||||
this.#dropdown.classList.remove("hidden");
|
this.#dropdown.classList.remove("hidden");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const root = (this.#dropdown = this.#getDropdownRoot(
|
const root = (this.#dropdown = this.#getDropdownRoot());
|
||||||
AnnotationEditorParamsType.HIGHLIGHT_COLOR
|
|
||||||
));
|
|
||||||
this.#button.append(root);
|
this.#button.append(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pointerDown(event) {
|
||||||
|
if (this.#dropdown?.contains(event.target)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.hideDropdown();
|
||||||
|
}
|
||||||
|
|
||||||
hideDropdown() {
|
hideDropdown() {
|
||||||
this.#dropdown?.classList.add("hidden");
|
this.#dropdown?.classList.add("hidden");
|
||||||
|
window.removeEventListener("pointerdown", this.#boundPointerDown);
|
||||||
}
|
}
|
||||||
|
|
||||||
_hideDropdownFromKeyboard() {
|
_hideDropdownFromKeyboard() {
|
||||||
|
@ -488,4 +488,46 @@ describe("Highlight Editor", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("Color picker and click outside", () => {
|
||||||
|
let pages;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await closePages(pages);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("must check that the dropdown is hidden", async () => {
|
||||||
|
await Promise.all(
|
||||||
|
pages.map(async ([browserName, page]) => {
|
||||||
|
await page.click("#editorHighlight");
|
||||||
|
await page.waitForSelector(".annotationEditorLayer.highlightEditing");
|
||||||
|
const sel = getEditorSelector(0);
|
||||||
|
|
||||||
|
const rect = await getSpanRectFromText(page, 1, "Abstract");
|
||||||
|
const x = rect.x + rect.width / 2;
|
||||||
|
const y = rect.y + rect.height / 2;
|
||||||
|
await page.mouse.click(x, y, { count: 2 });
|
||||||
|
|
||||||
|
await page.waitForSelector(sel);
|
||||||
|
await page.waitForSelector(
|
||||||
|
`.page[data-page-number = "1"] svg.highlightOutline.selected`
|
||||||
|
);
|
||||||
|
|
||||||
|
await page.waitForSelector(`${sel} .editToolbar button.colorPicker`);
|
||||||
|
await page.click(`${sel} .editToolbar button.colorPicker`);
|
||||||
|
await page.waitForSelector(
|
||||||
|
`${sel} .editToolbar button[title = "Red"]`
|
||||||
|
);
|
||||||
|
await page.mouse.click(x, y - rect.height);
|
||||||
|
await page.waitForSelector(
|
||||||
|
`${sel} .editToolbar button.colorPicker .dropdown.hidden`
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -1032,6 +1032,10 @@
|
|||||||
|
|
||||||
&:has(.dropdown:not(.hidden)) {
|
&:has(.dropdown:not(.hidden)) {
|
||||||
background-color: var(--editor-toolbar-hover-bg-color);
|
background-color: var(--editor-toolbar-hover-bg-color);
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
scale: -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown {
|
.dropdown {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user