Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calcite-modal: Option to prevent modal from returning focus when modal is removed from the DOM (when focus trap is enabled). #9369

Open
2 of 6 tasks
jmanke opened this issue May 18, 2024 · 1 comment
Labels
0 - new New issues that need assignment. ArcGIS Dashboards Issues logged by ArcGIS Dashboards team members. calcite-components Issues specific to the @esri/calcite-components package. enhancement Issues tied to a new feature or request. impact - p2 - want for an upcoming milestone User set priority impact status of p2 - want for an upcoming milestone p - low Issue is non core or affecting less that 10% of people using the library spike Issues that need quick investigations for time estimations, prioritization, or a quick assessment.

Comments

@jmanke
Copy link

jmanke commented May 18, 2024

Check existing issues

Description

Currently, when a modal with a focus trap is removed from the DOM, it refocuses on the previously active element. This causes issues when the modal is used to delete an item. After deletion, the focus trap attempts to refocus on the now-deleted item, leading to unintended scrolling behavior, especially when the item is in scrollable container.

Here's the workflow:

  1. Click a calcite-button within a calcite-card to trigger a deletion modal. (The card is within a scrollable container.)
  2. Confirm deletion.
  3. The item is deleted, and the modal is closed.
  4. The focus trap within the modal refocuses on the now-deleted item, causing unexpected scrolling behavior.

One solution could be to disable the focus trap during deletion. However, the focusTrapDisabled property is being deprecated according to this calcite issue.

An alternative could be to use the returnFocusOnDeactivate boolean property in the focus trap to disable this behavior (internally in calcite).

Acceptance Criteria

Ability to prevent a modal from automatically setting focus when disconnected from the DOM.

Relevant Info

Currently using [email protected]

Which Component

calcite-modal

Example Use Case

The modal is being used to delete an item, so when the item is deleted, the focus trap will attempt to refocus on that item, causing some unintended behaviors. In our case, the item is in a scrollable list so the focus is causing the list to scroll in unintended ways.

If there was some way to disable this refocus behavior, then the unintended scrolling behavior could be prevented and we could control where the focus instead needs to go.

Priority impact

p3 - want for upcoming milestone

Calcite package

  • @esri/calcite-components
  • @esri/calcite-components-angular
  • @esri/calcite-components-react
  • @esri/calcite-design-tokens
  • @esri/eslint-plugin-calcite-components

Esri team

ArcGIS Dashboards

@jmanke jmanke added 0 - new New issues that need assignment. enhancement Issues tied to a new feature or request. needs triage Planning workflow - pending design/dev review. labels May 18, 2024
@github-actions github-actions bot added p3 - want for upcoming milestone calcite-components Issues specific to the @esri/calcite-components package. ArcGIS Dashboards Issues logged by ArcGIS Dashboards team members. labels May 18, 2024
@geospatialem geospatialem added impact - p2 - want for an upcoming milestone User set priority impact status of p2 - want for an upcoming milestone and removed p3 - want for upcoming milestone labels May 21, 2024
@geospatialem geospatialem added p - low Issue is non core or affecting less that 10% of people using the library needs milestone Planning workflow - pending milestone assignment, has priority and/or estimate. spike Issues that need quick investigations for time estimations, prioritization, or a quick assessment. and removed needs triage Planning workflow - pending design/dev review. labels Dec 18, 2024
@geospatialem
Copy link
Member

Assigning as a spike to determine how to handle more advanced focus use cases.

@DitwanP DitwanP removed the needs milestone Planning workflow - pending milestone assignment, has priority and/or estimate. label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0 - new New issues that need assignment. ArcGIS Dashboards Issues logged by ArcGIS Dashboards team members. calcite-components Issues specific to the @esri/calcite-components package. enhancement Issues tied to a new feature or request. impact - p2 - want for an upcoming milestone User set priority impact status of p2 - want for an upcoming milestone p - low Issue is non core or affecting less that 10% of people using the library spike Issues that need quick investigations for time estimations, prioritization, or a quick assessment.
Projects
None yet
Development

No branches or pull requests

3 participants