|
@@ -128,7 +128,9 @@ const Picker = ({
|
|
}, []);
|
|
}, []);
|
|
|
|
|
|
const handleKeyDown = (event: React.KeyboardEvent) => {
|
|
const handleKeyDown = (event: React.KeyboardEvent) => {
|
|
|
|
+ let handled = false;
|
|
if (event.key === KEYS.TAB) {
|
|
if (event.key === KEYS.TAB) {
|
|
|
|
+ handled = true;
|
|
const { activeElement } = document;
|
|
const { activeElement } = document;
|
|
if (event.shiftKey) {
|
|
if (event.shiftKey) {
|
|
if (activeElement === firstItem.current) {
|
|
if (activeElement === firstItem.current) {
|
|
@@ -140,19 +142,19 @@ const Picker = ({
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
}
|
|
}
|
|
} else if (isArrowKey(event.key)) {
|
|
} else if (isArrowKey(event.key)) {
|
|
|
|
+ handled = true;
|
|
const { activeElement } = document;
|
|
const { activeElement } = document;
|
|
const isRTL = getLanguage().rtl;
|
|
const isRTL = getLanguage().rtl;
|
|
let isCustom = false;
|
|
let isCustom = false;
|
|
let index = Array.prototype.indexOf.call(
|
|
let index = Array.prototype.indexOf.call(
|
|
- gallery.current!.querySelector(".color-picker-content--default")!
|
|
|
|
- .children,
|
|
|
|
|
|
+ gallery.current!.querySelector(".color-picker-content--default")
|
|
|
|
+ ?.children,
|
|
activeElement,
|
|
activeElement,
|
|
);
|
|
);
|
|
if (index === -1) {
|
|
if (index === -1) {
|
|
index = Array.prototype.indexOf.call(
|
|
index = Array.prototype.indexOf.call(
|
|
- gallery.current!.querySelector(
|
|
|
|
- ".color-picker-content--canvas-colors",
|
|
|
|
- )!.children,
|
|
|
|
|
|
+ gallery.current!.querySelector(".color-picker-content--canvas-colors")
|
|
|
|
+ ?.children,
|
|
activeElement,
|
|
activeElement,
|
|
);
|
|
);
|
|
if (index !== -1) {
|
|
if (index !== -1) {
|
|
@@ -180,8 +182,11 @@ const Picker = ({
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
} else if (
|
|
} else if (
|
|
keyBindings.includes(event.key.toLowerCase()) &&
|
|
keyBindings.includes(event.key.toLowerCase()) &&
|
|
|
|
+ !event[KEYS.CTRL_OR_CMD] &&
|
|
|
|
+ !event.altKey &&
|
|
!isWritableElement(event.target)
|
|
!isWritableElement(event.target)
|
|
) {
|
|
) {
|
|
|
|
+ handled = true;
|
|
const index = keyBindings.indexOf(event.key.toLowerCase());
|
|
const index = keyBindings.indexOf(event.key.toLowerCase());
|
|
const isCustom = index >= MAX_DEFAULT_COLORS;
|
|
const isCustom = index >= MAX_DEFAULT_COLORS;
|
|
const parentElement = isCustom
|
|
const parentElement = isCustom
|
|
@@ -196,11 +201,14 @@ const Picker = ({
|
|
|
|
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
} else if (event.key === KEYS.ESCAPE || event.key === KEYS.ENTER) {
|
|
} else if (event.key === KEYS.ESCAPE || event.key === KEYS.ENTER) {
|
|
|
|
+ handled = true;
|
|
event.preventDefault();
|
|
event.preventDefault();
|
|
onClose();
|
|
onClose();
|
|
}
|
|
}
|
|
- event.nativeEvent.stopImmediatePropagation();
|
|
|
|
- event.stopPropagation();
|
|
|
|
|
|
+ if (handled) {
|
|
|
|
+ event.nativeEvent.stopImmediatePropagation();
|
|
|
|
+ event.stopPropagation();
|
|
|
|
+ }
|
|
};
|
|
};
|
|
|
|
|
|
const renderColors = (colors: Array<string>, custom: boolean = false) => {
|
|
const renderColors = (colors: Array<string>, custom: boolean = false) => {
|