fix(card): Update full-screen focus trap logic #701
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes from #662 have affected the visibility and tab focus order of the full screen enter button. This PR updates the focus trap logic in two ways:
Because the full screen enter button retains focus when entering full screen mode, we now detect this case and move focus to the parent card when making the card full screen. We also do this step a little later (after adjusting the full screen attribute and setting classes on the document body).
The full screen enter button is included in the list of focusable elements, even when the card is in full screen. Helpfully, it's always the last element. We remove it from our list of focusable elements so that we skip it when the user reaches the end of the card.
This issue was uncovered by 313-bslib-card-tab-focus.
For rstudio/shinycoreci#195