@primer/behaviors 0.0.0-20251028143104 → 0.0.0-20251028164006

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.
@@ -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 (activeElement instanceof HTMLSelectElement) {
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
- if (isInputElement) {
101
- const cursorAtStart = activeElement.selectionStart === 0 && activeElement.selectionEnd === 0;
102
- const cursorAtEnd = 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;
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) {
@@ -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 (activeElement instanceof HTMLSelectElement) {
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
- if (isInputElement) {
99
- const cursorAtStart = activeElement.selectionStart === 0 && activeElement.selectionEnd === 0;
100
- const cursorAtEnd = activeElement.selectionStart === activeElement.value.length &&
101
- activeElement.selectionEnd === activeElement.value.length;
102
- if (key === 'ArrowLeft' && !cursorAtStart) {
103
- return true;
104
- }
105
- if (key === 'ArrowRight' && !cursorAtEnd) {
106
- return true;
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/behaviors",
3
- "version": "0.0.0-20251028143104",
3
+ "version": "0.0.0-20251028164006",
4
4
  "description": "Shared behaviors for JavaScript components",
5
5
  "type": "commonjs",
6
6
  "main": "dist/cjs/index.js",