Skip to content

Commit

Permalink
fix focus bug
Browse files Browse the repository at this point in the history
  • Loading branch information
KingSora committed Apr 5, 2024
1 parent 8c390b1 commit 812ee95
Showing 1 changed file with 4 additions and 5 deletions.
Expand Up @@ -244,11 +244,6 @@ export const createStructureSetupElements = (

push(destroyFns, [
undoInitWrapUndwrapFocus,
!viewportIsTarget &&
(() =>
ogTabindex
? setAttrs(_viewport, tabIndexStr, ogTabindex)
: removeAttrs(_viewport, tabIndexStr)),
() => {
const destroyActiveElm = getFocusedElement();
const undoDestroyWrapUndwrapFocus = prepareWrapUnwrapFocus(destroyActiveElm);
Expand All @@ -259,6 +254,9 @@ export const createStructureSetupElements = (
dataAttributeHostOverflowY,
dataAttributeViewport,
]);
ogTabindex
? setAttrs(_viewport, tabIndexStr, ogTabindex)
: removeAttrs(_viewport, tabIndexStr);

elementIsGenerated(_content) && unwrap(_content);
elementIsGenerated(_viewport) && unwrap(_viewport);
Expand All @@ -273,6 +271,7 @@ export const createStructureSetupElements = (
push(destroyFns, bind(removeAttrs, _viewport, dataAttributeViewport));
}

// focus viewport if previously focused element was target, otherwise focus previously focused element
focusElm(
!viewportIsTarget && docWnd.top === docWnd && initActiveElm === targetElement
? _viewport
Expand Down

0 comments on commit 812ee95

Please sign in to comment.