fix(files_sharing): select sharing in sidebar breaks Viewer focus trap #40273
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.
Summary
What's happening in the mentioned PR:
SharingInput
emits global eventviewer:trapElements:changed
sending theNcSelect
instanceViewer
handles this event and adds thisNcSelect
instance to the@nextcloud/vue/NcModal
additional trap elementsWhy there was a problem:
Each time a select is open, a global event triggers
viewer
which then adds thisselect
asadditionalTrapElement
. As the result:select
becomes a newtabbableGroup
which is supposed to be already a part of sidebar group.On first open it works fine. On the second and following it breaks. When a user is in the open select again and presses TAB the following happens:
focus-trap
searches the firsttabbableGroup
withselect
tabbableGroup
tabbableGroup
is the a group withselect
again.focus-trap
focuses the same select again.See also: https://github.com/focus-trap/focus-trap/blob/c68a1ca87f2dfd905d9f97b91e2d0318268b5ea3/index.js#L529-L535
Why the fix from the mentioned PR is not needed now:
It is fixed globally by nextcloud-libraries/nextcloud-vue#4406 (see: nextcloud-libraries/nextcloud-vue@f6a6de1).
When
additionalTrapElements
are taken into account on init, select works as a part of the sidebar which is already added intoadditionalTrapElements
.TODO
viewer:trapElements:changed
on each sharing select open in sidebarScreenshots
Alternative or additional solution
In
NcModal
or/andViewer
we can check that there are no duplications inadditionalTrapElements
.Folowing-up
There is still a problem with a focus on "Copy internal link button". Not related to this PR, but could be a related problem...
Checklist