mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
[Editor] Change the arrow direction when the dropdown is visible in the color picker (bug 1875357)
and hide the dropdown when the user click outside of the color picker.
This commit is contained in:
parent
1cdbcfef82
commit
a1bf12537c
3 changed files with 58 additions and 3 deletions
|
@ -20,6 +20,8 @@ import { noContextMenu } from "../display_utils.js";
|
|||
class ColorPicker {
|
||||
#boundKeyDown = this.#keyDown.bind(this);
|
||||
|
||||
#boundPointerDown = this.#pointerDown.bind(this);
|
||||
|
||||
#button = null;
|
||||
|
||||
#buttonSwatch = null;
|
||||
|
@ -177,18 +179,25 @@ class ColorPicker {
|
|||
}
|
||||
this.#button.addEventListener("keydown", this.#boundKeyDown);
|
||||
this.#dropdownWasFromKeyboard = event.detail === 0;
|
||||
window.addEventListener("pointerdown", this.#boundPointerDown);
|
||||
if (this.#dropdown) {
|
||||
this.#dropdown.classList.remove("hidden");
|
||||
return;
|
||||
}
|
||||
const root = (this.#dropdown = this.#getDropdownRoot(
|
||||
AnnotationEditorParamsType.HIGHLIGHT_COLOR
|
||||
));
|
||||
const root = (this.#dropdown = this.#getDropdownRoot());
|
||||
this.#button.append(root);
|
||||
}
|
||||
|
||||
#pointerDown(event) {
|
||||
if (this.#dropdown?.contains(event.target)) {
|
||||
return;
|
||||
}
|
||||
this.hideDropdown();
|
||||
}
|
||||
|
||||
hideDropdown() {
|
||||
this.#dropdown?.classList.add("hidden");
|
||||
window.removeEventListener("pointerdown", this.#boundPointerDown);
|
||||
}
|
||||
|
||||
_hideDropdownFromKeyboard() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue