Skip to content

UI: Fix modal text selection#33967

Merged
Sidnioulz merged 1 commit intonextfrom
sidnioulz/fix-modal-text-selection
Mar 4, 2026
Merged

UI: Fix modal text selection#33967
Sidnioulz merged 1 commit intonextfrom
sidnioulz/fix-modal-text-selection

Conversation

@Sidnioulz
Copy link
Copy Markdown
Member

@Sidnioulz Sidnioulz commented Mar 2, 2026

What I did

Text selection was kinda buggy in our Modal. Turns out this is a known issue with how React Aria enforces focus traps. They provide a workaround (div tabIndex={-1} around the Modal content), so this PR applies it.

The PR also makes minor changes to the GlobalErrorModal for more coherent title capitalisation (@MichaelArestad feel free to give instructions on that).

Checklist for Contributors

Testing

Manual testing

  1. Go to http://localhost:6006/?path=/story/addons-vitest-globalerrormodal--fatal-error
  2. Select text in the modal

Documentation

ø

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli-storybook/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>

Summary by CodeRabbit

  • Bug Fixes

    • Corrected error message text from "Storybook Tests" to "Storybook Test" for consistency.
  • Improvements

    • Users can now select and copy text from error stack traces in the modal.
    • Enhanced focus management in modal interactions for better accessibility.

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Mar 2, 2026

View your CI Pipeline Execution ↗ for commit ba13166

Command Status Duration Result
nx run-many -t compile,check,knip,test,pretty-d... ❌ Failed 12m 11s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-02 11:21:21 UTC

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bf19c7b and ba13166.

📒 Files selected for processing (3)
  • code/addons/vitest/src/components/GlobalErrorModal.stories.tsx
  • code/addons/vitest/src/components/GlobalErrorModal.tsx
  • code/core/src/components/components/Modal/Modal.tsx

📝 Walkthrough

Walkthrough

These changes update UI text strings for consistency ("Tests" to "Test" in error modals), add text selection styling to error stack trace display, and improve focus management in the Modal component by wrapping its container with a tabIndex attribute.

Changes

Cohort / File(s) Summary
Error Modal UI Updates
code/addons/vitest/src/components/GlobalErrorModal.tsx, code/addons/vitest/src/components/GlobalErrorModal.stories.tsx
Updates text strings from "Storybook Tests error details" to "Storybook Test Error Details" in both the modal's aria-label and title. Adds userSelect: 'text' CSS to the ModalStackTrace pre element to enable text selection in error details.
Modal Focus Management
code/core/src/components/components/Modal/Modal.tsx
Wraps Modal.Container inside a new div with tabIndex={-1} to improve focus scope management, preserving the container's props and children while adding an intermediate DOM element for focus handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • #33326 — Modifies Modal implementation including focus/container behavior and ARIA attributes alongside modal-related styling updates.
✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)

Comment @coderabbitai help to get the list of available commands and usage tips.

@Sidnioulz Sidnioulz merged commit 52a6b3b into next Mar 4, 2026
123 of 134 checks passed
@Sidnioulz Sidnioulz deleted the sidnioulz/fix-modal-text-selection branch March 4, 2026 11:22
@Sidnioulz Sidnioulz added needs qa Indicates that this needs manual QA during the upcoming minor/major release and removed needs qa Indicates that this needs manual QA during the upcoming minor/major release labels Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants