Skip to content

Improve focus-trap behavior of modal container  #17104

@IsaSih

Description

@IsaSih

Setup

  • Rancher version:

Rancher v2.14.0
Dashboard v2.14.0

Describe the bug
Found while fixing rancher/qa-tasks#2270

There's a workaround in place to test downloading the diagnostics package JSON. We're using cy.on('uncaught:exception') to ignore known failures due to AppModal.vue that always activates a focus-trap on modal-container-element, but in this e2e test diagnostic.spec.ts, the modal is being closed so quickly (right after clicking “download”) that the trap is still activating while the container has no tabbable elements. When focus-trap activates and can’t find any tabbable node inside its container, it throws:

“Your focus-trap must have at least one container with at least one tabbable node in it at all times.”

To Reproduce

Run diagnostic.spec.ts in CI.

Result
AppModal.vue is wiring the trap by watching a variable and then calling createFocusTrap(...).activate() on #modal-container-element, resulting in the test failure.

Expected Result
The modal container must be programmatically focusable and provide a fallbackFocus for focus-trap, so this error does not fire when tabbable controls are temporarily unavailable.

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions