nextcloud-vue icon indicating copy to clipboard operation
nextcloud-vue copied to clipboard

Recursive calls of focusTrap() in NcActions component

Open raimund-schluessler opened this issue 3 years ago • 3 comments

This might be a problem of floating-vue: Akryum/floating-vue#872 actually, which automatically gives the focus to the popover. One can actually see, that the first action has focus for a short amount of time, and then loses it again. I don't see a way to disable this behavior, so the timeout might be our best option for now.

I have a problem indirectly related to this.

I didn't find the root cause, but I guess it is related to multiple focus traps activate at the same time.

focusElement.focus() is causing recursive calls of focus trap.

image

image

Originally posted by @vinicius73 in https://github.com/nextcloud/nextcloud-vue/issues/3151#issuecomment-1234755061

raimund-schluessler avatar Sep 02 '22 06:09 raimund-schluessler

@vinicius73 Since I think this is a problem different from the one approached in #3151, I created a new issue.

However, what I realized while debugging #3151 is that this: https://github.com/nextcloud/nextcloud-vue/blob/1ef7b682202424ca1fdeaa9fdd5509486fefc4c0/src/components/NcActions/NcActions.vue#L774-L791 is called on every mouse move in the actions. Hence, your line in question https://github.com/nextcloud/nextcloud-vue/blob/master/src/components/NcActions/NcActions.vue#L832 is also called on nearly every move (depends a bit what is hovered). So this might create trouble with the focus trap, but I didn't check further so far.

Anyway, I think how we focus an Action on mouseover/move needs refactoring, since there is to much going on for a simple focus that should be called once and not on every mouse move. Maybe this could solve the focusTrap issue as well.

raimund-schluessler avatar Sep 02 '22 07:09 raimund-schluessler

https://github.com/focus-trap/focus-trap/issues/428

vinicius73 avatar Sep 12 '22 17:09 vinicius73

This recursion happens if there are two competing focus traps. In text vinicius is fixing it by moving the Menubar (which had focus traps for the dropdowns) into the modal which was also using focus traps. Now one focus trap is inside the other which is fine.

However this is not an option currently for NcActions in the sidebar when the modal is open. Sidebar lives outside of the modal and so do all of its children. So they compete with the focus trap of the modal.

max-nextcloud avatar Sep 27 '22 14:09 max-nextcloud