@primer/behaviors 0.0.0-20251203163923 → 0.0.0-20251203200457

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.
@@ -25,7 +25,7 @@ export type FocusZoneSettings = IterateFocusableElements & {
25
25
  abortSignal?: AbortSignal;
26
26
  activeDescendantControl?: HTMLElement;
27
27
  onActiveDescendantChanged?: (newActiveDescendant: HTMLElement | undefined, previousActiveDescendant: HTMLElement | undefined, directlyActivated: boolean) => void;
28
- focusInStrategy?: 'first' | 'closest' | 'previous' | 'initial' | ((previousFocusedElement: Element) => HTMLElement | undefined);
28
+ focusInStrategy?: 'first' | 'closest' | 'previous' | ((previousFocusedElement: Element) => HTMLElement | undefined);
29
29
  preventScroll?: boolean;
30
30
  };
31
31
  export declare const isActiveDescendantAttribute = "data-is-active-descendant";
@@ -202,7 +202,7 @@ function focusZone(container, settings) {
202
202
  }
203
203
  element.setAttribute('tabindex', '-1');
204
204
  }
205
- if (!currentFocusedElement && focusInStrategy !== 'initial') {
205
+ if (!currentFocusedElement) {
206
206
  updateFocusedElement(getFirstFocusableElement());
207
207
  }
208
208
  }
@@ -256,8 +256,7 @@ function focusZone(container, settings) {
256
256
  };
257
257
  beginFocusManagement(...iterateFocusableElements.iterateFocusableElements(container, iterateFocusableElementsOptions));
258
258
  const initialElement = typeof focusInStrategy === 'function' ? focusInStrategy(document.body) : getFirstFocusableElement();
259
- if (focusInStrategy !== 'initial')
260
- updateFocusedElement(initialElement);
259
+ updateFocusedElement(initialElement);
261
260
  const observer = new MutationObserver(mutations => {
262
261
  for (const mutation of mutations) {
263
262
  for (const removedNode of mutation.removedNodes) {
@@ -319,8 +318,7 @@ function focusZone(container, settings) {
319
318
  }, { signal, capture: true });
320
319
  activeDescendantControl.addEventListener('focusin', () => {
321
320
  if (!currentFocusedElement) {
322
- if (focusInStrategy !== 'initial')
323
- updateFocusedElement(getFirstFocusableElement());
321
+ updateFocusedElement(getFirstFocusableElement());
324
322
  }
325
323
  else {
326
324
  setActiveDescendant(undefined, currentFocusedElement);
@@ -388,7 +386,7 @@ function focusZone(container, settings) {
388
386
  }
389
387
  function getCurrentFocusedIndex() {
390
388
  if (!currentFocusedElement) {
391
- return focusInStrategy === 'initial' ? -1 : 0;
389
+ return 0;
392
390
  }
393
391
  const focusedIndex = focusableElements.indexOf(currentFocusedElement);
394
392
  const fallbackIndex = currentFocusedElement === container ? -1 : 0;
@@ -25,7 +25,7 @@ export type FocusZoneSettings = IterateFocusableElements & {
25
25
  abortSignal?: AbortSignal;
26
26
  activeDescendantControl?: HTMLElement;
27
27
  onActiveDescendantChanged?: (newActiveDescendant: HTMLElement | undefined, previousActiveDescendant: HTMLElement | undefined, directlyActivated: boolean) => void;
28
- focusInStrategy?: 'first' | 'closest' | 'previous' | 'initial' | ((previousFocusedElement: Element) => HTMLElement | undefined);
28
+ focusInStrategy?: 'first' | 'closest' | 'previous' | ((previousFocusedElement: Element) => HTMLElement | undefined);
29
29
  preventScroll?: boolean;
30
30
  };
31
31
  export declare const isActiveDescendantAttribute = "data-is-active-descendant";
@@ -200,7 +200,7 @@ function focusZone(container, settings) {
200
200
  }
201
201
  element.setAttribute('tabindex', '-1');
202
202
  }
203
- if (!currentFocusedElement && focusInStrategy !== 'initial') {
203
+ if (!currentFocusedElement) {
204
204
  updateFocusedElement(getFirstFocusableElement());
205
205
  }
206
206
  }
@@ -254,8 +254,7 @@ function focusZone(container, settings) {
254
254
  };
255
255
  beginFocusManagement(...iterateFocusableElements(container, iterateFocusableElementsOptions));
256
256
  const initialElement = typeof focusInStrategy === 'function' ? focusInStrategy(document.body) : getFirstFocusableElement();
257
- if (focusInStrategy !== 'initial')
258
- updateFocusedElement(initialElement);
257
+ updateFocusedElement(initialElement);
259
258
  const observer = new MutationObserver(mutations => {
260
259
  for (const mutation of mutations) {
261
260
  for (const removedNode of mutation.removedNodes) {
@@ -317,8 +316,7 @@ function focusZone(container, settings) {
317
316
  }, { signal, capture: true });
318
317
  activeDescendantControl.addEventListener('focusin', () => {
319
318
  if (!currentFocusedElement) {
320
- if (focusInStrategy !== 'initial')
321
- updateFocusedElement(getFirstFocusableElement());
319
+ updateFocusedElement(getFirstFocusableElement());
322
320
  }
323
321
  else {
324
322
  setActiveDescendant(undefined, currentFocusedElement);
@@ -386,7 +384,7 @@ function focusZone(container, settings) {
386
384
  }
387
385
  function getCurrentFocusedIndex() {
388
386
  if (!currentFocusedElement) {
389
- return focusInStrategy === 'initial' ? -1 : 0;
387
+ return 0;
390
388
  }
391
389
  const focusedIndex = focusableElements.indexOf(currentFocusedElement);
392
390
  const fallbackIndex = currentFocusedElement === container ? -1 : 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/behaviors",
3
- "version": "0.0.0-20251203163923",
3
+ "version": "0.0.0-20251203200457",
4
4
  "description": "Shared behaviors for JavaScript components",
5
5
  "type": "commonjs",
6
6
  "main": "dist/cjs/index.js",