@primer/behaviors 0.0.0-20251027175934 → 0.0.0-20251028155318
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/focus-zone.js +13 -12
- package/dist/esm/focus-zone.mjs +13 -12
- package/package.json +1 -1
package/dist/cjs/focus-zone.js
CHANGED
|
@@ -84,29 +84,30 @@ function shouldIgnoreFocusHandling(keyboardEvent, activeElement) {
|
|
|
84
84
|
const key = keyboardEvent.key;
|
|
85
85
|
const keyLength = [...key].length;
|
|
86
86
|
const isEditable = isEditableElement.isEditableElement(activeElement);
|
|
87
|
+
const isSelect = activeElement instanceof HTMLSelectElement;
|
|
87
88
|
if (isEditable && (keyLength === 1 || key === 'Home' || key === 'End')) {
|
|
88
89
|
return true;
|
|
89
90
|
}
|
|
90
|
-
if (
|
|
91
|
+
if (isSelect) {
|
|
91
92
|
if (key === 'ArrowDown' && userAgent.isMacOS() && !keyboardEvent.metaKey) {
|
|
92
93
|
return true;
|
|
93
94
|
}
|
|
94
95
|
if (key === 'ArrowDown' && !userAgent.isMacOS() && keyboardEvent.altKey) {
|
|
95
96
|
return true;
|
|
96
97
|
}
|
|
98
|
+
return false;
|
|
97
99
|
}
|
|
98
|
-
if (isEditable) {
|
|
100
|
+
if (isEditable && !isSelect) {
|
|
99
101
|
const isInputElement = activeElement instanceof HTMLTextAreaElement || activeElement instanceof HTMLInputElement;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
102
|
+
const cursorAtStart = isInputElement && activeElement.selectionStart === 0 && activeElement.selectionEnd === 0;
|
|
103
|
+
const cursorAtEnd = isInputElement &&
|
|
104
|
+
activeElement.selectionStart === activeElement.value.length &&
|
|
105
|
+
activeElement.selectionEnd === activeElement.value.length;
|
|
106
|
+
if (key === 'ArrowLeft' && !cursorAtStart) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
if (key === 'ArrowRight' && !cursorAtEnd) {
|
|
110
|
+
return true;
|
|
110
111
|
}
|
|
111
112
|
const isContentEditable = activeElement instanceof HTMLElement && activeElement.isContentEditable;
|
|
112
113
|
if (activeElement instanceof HTMLTextAreaElement || isContentEditable) {
|
package/dist/esm/focus-zone.mjs
CHANGED
|
@@ -82,29 +82,30 @@ function shouldIgnoreFocusHandling(keyboardEvent, activeElement) {
|
|
|
82
82
|
const key = keyboardEvent.key;
|
|
83
83
|
const keyLength = [...key].length;
|
|
84
84
|
const isEditable = isEditableElement(activeElement);
|
|
85
|
+
const isSelect = activeElement instanceof HTMLSelectElement;
|
|
85
86
|
if (isEditable && (keyLength === 1 || key === 'Home' || key === 'End')) {
|
|
86
87
|
return true;
|
|
87
88
|
}
|
|
88
|
-
if (
|
|
89
|
+
if (isSelect) {
|
|
89
90
|
if (key === 'ArrowDown' && isMacOS() && !keyboardEvent.metaKey) {
|
|
90
91
|
return true;
|
|
91
92
|
}
|
|
92
93
|
if (key === 'ArrowDown' && !isMacOS() && keyboardEvent.altKey) {
|
|
93
94
|
return true;
|
|
94
95
|
}
|
|
96
|
+
return false;
|
|
95
97
|
}
|
|
96
|
-
if (isEditable) {
|
|
98
|
+
if (isEditable && !isSelect) {
|
|
97
99
|
const isInputElement = activeElement instanceof HTMLTextAreaElement || activeElement instanceof HTMLInputElement;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
100
|
+
const cursorAtStart = isInputElement && activeElement.selectionStart === 0 && activeElement.selectionEnd === 0;
|
|
101
|
+
const cursorAtEnd = isInputElement &&
|
|
102
|
+
activeElement.selectionStart === activeElement.value.length &&
|
|
103
|
+
activeElement.selectionEnd === activeElement.value.length;
|
|
104
|
+
if (key === 'ArrowLeft' && !cursorAtStart) {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
if (key === 'ArrowRight' && !cursorAtEnd) {
|
|
108
|
+
return true;
|
|
108
109
|
}
|
|
109
110
|
const isContentEditable = activeElement instanceof HTMLElement && activeElement.isContentEditable;
|
|
110
111
|
if (activeElement instanceof HTMLTextAreaElement || isContentEditable) {
|