[terra-form-select] Non-enabled and invisible content is interactable and causing inconsistent hovers
See original GitHub issueBug Report
Description
Hookshot’s API provides an isEnabled
property that can be toggled on and off. When isEnabled is false the content is positioned in the top left corner of the screen with an opacity of 0 to make it invisible to users. The invisible content is mouse interactable and overlays the screen.
Steps to Reproduce
Here’s a sample code sandbox: https://codesandbox.io/s/eager-maxwell-spi0e
- Open the code sandbox.
- Click around on the example page, but do not click the button to open hookshot yet.
- Observe all of the click events are being counted.
- Click the button to open hookshot.
- Attempt to click anywhere on the page.
- Observe the click count is not changing, but the background color is.
This example demonstrates interacting with invisible hookshot content. The invisible content is overlayed on top of the visible content. The visible content is no longer interactable. Any attempt to interact with it will interact with the invisible hookshot content.
Additional Context / Screenshots
This issue came up with the Select component. Opening the terra-form-select would occasionally cause inconsistent results with the hover interactions of the dropdown menu. Opening the Select dropdown would appear to cause a hover interaction with the list of options. This was happening because the the invisible dropdown content is still interactable and would invoke a mouse enter event on the non-enabled dropdown.
Expected Behavior
Invisible content should not be mouse/keyboard interactable.
Possible Solution
Set the default style of the hookshot content to pointer-events: none
when invisible. Note: This is not fully supported in IE 10. An overlay or different combination of CSS may be necessary.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
I was not aware of this and assuming setting isEnabled false will re-hide the hookshot. Well then it makes sense to add
inert
changes in form-select. while testinginert
logic I found a scenario where focus was not setting toul
menu element even after removinginert
from hookshot div.Due to this focus still remains on frame even when dropdown is open. this prevents dropdown from closing on
placeholder
click as shown in below image. (we can see that active element still points to frame div instead oful
menu on dropdown open.Focus to
ul
menu is set bymoveFocusToDropDown
method in frame. but programmatic focus doesn’t seems to be set focus onul
menu after removinginert
element from its parent element (hookshot-div).After some investigation around
inert
i found similar issue inwcig-inert
where it fails to restore tab-index on elements likeul
,li
andol
on removing inert from the element.To fix this issue of focus not setting on
ul
menu on open we might need to restore thetab-index
by resetting the tab-index oful
element after removinginert
from div like below.Since we require this change as well I think form-select would be the right place to add
inert
logic to fix this issue. we can addinert
to dropdown before it is positioned and removeinert
when dropdown is positioned.The issue is addressed within terra-form-select. Hence is moved from terra-framework to terra-core.
Issue title and description will be suitably modified.