@primer/behaviors 1.9.2-rc.45ff0ed → 1.10.0-rc.8ac56be
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 +22 -2
- package/dist/esm/focus-zone.mjs +22 -2
- package/package.json +1 -1
package/dist/cjs/focus-zone.js
CHANGED
|
@@ -214,10 +214,25 @@ function focusZone(container, settings) {
|
|
|
214
214
|
element.setAttribute('tabindex', '-1');
|
|
215
215
|
}
|
|
216
216
|
const shouldFocusPrepended = focusPrependedElements && insertionIndex === 0 && !wasDirectlyActivated;
|
|
217
|
-
if (!preventInitialFocus &&
|
|
217
|
+
if (!preventInitialFocus && shouldFocusPrepended) {
|
|
218
|
+
reinitializeWithFreshElements();
|
|
219
|
+
}
|
|
220
|
+
else if (!preventInitialFocus && !currentFocusedElement) {
|
|
218
221
|
updateFocusedElement(getFirstFocusableElement());
|
|
219
222
|
}
|
|
220
223
|
}
|
|
224
|
+
function reinitializeWithFreshElements() {
|
|
225
|
+
const freshElements = [...iterateFocusableElements.iterateFocusableElements(container, iterateFocusableElementsOptions)];
|
|
226
|
+
focusableElements.clear();
|
|
227
|
+
focusableElements.insertAt(0, ...freshElements);
|
|
228
|
+
for (const element of freshElements) {
|
|
229
|
+
if (!savedTabIndex.has(element)) {
|
|
230
|
+
savedTabIndex.set(element, element.getAttribute('tabindex'));
|
|
231
|
+
}
|
|
232
|
+
element.setAttribute('tabindex', '-1');
|
|
233
|
+
}
|
|
234
|
+
updateFocusedElement(getFirstFocusableElement());
|
|
235
|
+
}
|
|
221
236
|
function findInsertionIndex(elementsToInsert) {
|
|
222
237
|
const firstElementToInsert = elementsToInsert[0];
|
|
223
238
|
if (focusableElements.size === 0)
|
|
@@ -318,7 +333,12 @@ function focusZone(container, settings) {
|
|
|
318
333
|
}
|
|
319
334
|
}
|
|
320
335
|
if (toAdd.length > 0) {
|
|
321
|
-
|
|
336
|
+
if (focusPrependedElements) {
|
|
337
|
+
reinitializeWithFreshElements();
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
beginFocusManagement(...toAdd);
|
|
341
|
+
}
|
|
322
342
|
}
|
|
323
343
|
}
|
|
324
344
|
if (attributeAdditions.size > 0) {
|
package/dist/esm/focus-zone.mjs
CHANGED
|
@@ -212,10 +212,25 @@ function focusZone(container, settings) {
|
|
|
212
212
|
element.setAttribute('tabindex', '-1');
|
|
213
213
|
}
|
|
214
214
|
const shouldFocusPrepended = focusPrependedElements && insertionIndex === 0 && !wasDirectlyActivated;
|
|
215
|
-
if (!preventInitialFocus &&
|
|
215
|
+
if (!preventInitialFocus && shouldFocusPrepended) {
|
|
216
|
+
reinitializeWithFreshElements();
|
|
217
|
+
}
|
|
218
|
+
else if (!preventInitialFocus && !currentFocusedElement) {
|
|
216
219
|
updateFocusedElement(getFirstFocusableElement());
|
|
217
220
|
}
|
|
218
221
|
}
|
|
222
|
+
function reinitializeWithFreshElements() {
|
|
223
|
+
const freshElements = [...iterateFocusableElements(container, iterateFocusableElementsOptions)];
|
|
224
|
+
focusableElements.clear();
|
|
225
|
+
focusableElements.insertAt(0, ...freshElements);
|
|
226
|
+
for (const element of freshElements) {
|
|
227
|
+
if (!savedTabIndex.has(element)) {
|
|
228
|
+
savedTabIndex.set(element, element.getAttribute('tabindex'));
|
|
229
|
+
}
|
|
230
|
+
element.setAttribute('tabindex', '-1');
|
|
231
|
+
}
|
|
232
|
+
updateFocusedElement(getFirstFocusableElement());
|
|
233
|
+
}
|
|
219
234
|
function findInsertionIndex(elementsToInsert) {
|
|
220
235
|
const firstElementToInsert = elementsToInsert[0];
|
|
221
236
|
if (focusableElements.size === 0)
|
|
@@ -316,7 +331,12 @@ function focusZone(container, settings) {
|
|
|
316
331
|
}
|
|
317
332
|
}
|
|
318
333
|
if (toAdd.length > 0) {
|
|
319
|
-
|
|
334
|
+
if (focusPrependedElements) {
|
|
335
|
+
reinitializeWithFreshElements();
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
beginFocusManagement(...toAdd);
|
|
339
|
+
}
|
|
320
340
|
}
|
|
321
341
|
}
|
|
322
342
|
if (attributeAdditions.size > 0) {
|