-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
A11y: Make resize handles for addon panel and sidebar accessible #33980
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
Merged
+1,030
−97
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
03cf9ff
Initial plan
Copilot 9f380ec
feat(a11y): make resize handles for addon panel and sidebar accessible
Copilot 8e0fbf5
refactor(a11y): address review feedback on resize handles
Copilot 2082668
refactor(a11y): rework resize handles based on next branch structure
Copilot b5b2969
Refactor smelly code and rebase leftovers
Sidnioulz feeb794
feat(a11y): add SidebarContainer with focus management for sidebar to…
Copilot a128609
Fix element IDs for landmark animations
Sidnioulz 2a6729a
fix: forced-colors focus style, normalize position fallback, effectiv…
Copilot 39f2598
Fix max size calculations
Sidnioulz bfe66b6
Make size compute code safer
Sidnioulz b222bbe
Fix layoutCustomisation size calc bug
Sidnioulz e1eb8e6
Apply suggestion from @JReinhold
Sidnioulz f6fd0c0
Address PR feedback
Sidnioulz 8a60245
Improve stories
Sidnioulz c419134
Match mouse drag behaviour for KB useDragging
Sidnioulz afc7a55
Rework logic for hidden addon panel story
Sidnioulz 71afd18
Improve Drag stories
Sidnioulz b7c8a37
Merge branch 'next' into copilot/fix-addon-panel-accessibility
Sidnioulz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
274 changes: 274 additions & 0 deletions
274
code/core/src/manager/components/layout/Drag.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,274 @@ | ||
| import React from 'react'; | ||
|
|
||
| import type { Meta, StoryObj } from '@storybook/react-vite'; | ||
|
|
||
| import { expect, userEvent, within } from 'storybook/test'; | ||
|
|
||
| import { Drag } from './Drag'; | ||
|
|
||
| /** | ||
| * Presentational drag-handle component used for the sidebar and addon-panel resizers. | ||
| * | ||
| * Covers positioning, tooltips and hover/focus states, and ARIA attribute markup. The actual | ||
| * keyboard-resize logic lives in `useDragging` and can be tested in Layout stories. | ||
| */ | ||
| const meta = { | ||
| title: 'Layout/Drag', | ||
| component: Drag, | ||
| parameters: { | ||
| layout: 'centered', | ||
| }, | ||
| decorators: [ | ||
| (storyFn) => ( | ||
| // Drag uses `position: absolute` so it needs a positioned parent. | ||
| <div | ||
| style={{ | ||
| position: 'relative', | ||
| width: 200, | ||
| height: 200, | ||
| border: '2px dashed #aaa', | ||
| background: 'thistle', | ||
| }} | ||
| > | ||
| {storyFn()} | ||
| </div> | ||
| ), | ||
| ], | ||
| } satisfies Meta<typeof Drag>; | ||
|
|
||
| export default meta; | ||
|
|
||
| type Story = StoryObj<typeof meta>; | ||
|
|
||
| export const PositionLeft: Story = { | ||
| name: 'Position: left (sidebar)', | ||
| args: { | ||
| position: 'left', | ||
| 'aria-label': 'Sidebar resize handle', | ||
| 'aria-valuenow': 200, | ||
| 'aria-valuemax': 500, | ||
| }, | ||
| play: async ({ canvas, step }) => { | ||
| const handle = canvas.getByRole('separator'); | ||
|
|
||
| await step('Has aria-orientation="vertical" for left position', async () => { | ||
| expect(handle).toHaveAttribute('aria-orientation', 'vertical'); | ||
| }); | ||
|
|
||
| await step('Shows on the right of the parent element', async () => { | ||
| handle.focus(); | ||
| const parentRect = handle.parentElement?.getBoundingClientRect(); | ||
| const handleRect = handle.getBoundingClientRect(); | ||
| expect(handleRect.left).toBeGreaterThan(parentRect?.left ?? 0); | ||
| }); | ||
| }, | ||
| }; | ||
|
|
||
| export const PositionRight: Story = { | ||
| name: 'Position: right (addon panel)', | ||
| args: { | ||
| position: 'right', | ||
| 'aria-label': 'Addon panel resize handle', | ||
| 'aria-valuenow': 300, | ||
| 'aria-valuemax': 600, | ||
| }, | ||
| play: async ({ canvas, step }) => { | ||
| const handle = canvas.getByRole('separator'); | ||
|
|
||
| await step('Has aria-orientation="vertical" for right position', async () => { | ||
| expect(handle).toHaveAttribute('aria-orientation', 'vertical'); | ||
| }); | ||
|
|
||
| await step('Shows on the left of the parent element', async () => { | ||
| handle.focus(); | ||
| const parentRect = handle.parentElement?.getBoundingClientRect(); | ||
| const handleRect = handle.getBoundingClientRect(); | ||
| expect(handleRect.left).toBeLessThan(parentRect?.left ?? 0); | ||
| }); | ||
| }, | ||
| }; | ||
|
|
||
| export const PositionBottom: Story = { | ||
| name: 'Position: bottom (bottom panel)', | ||
| args: { | ||
| position: 'bottom', | ||
| 'aria-label': 'Addon panel resize handle', | ||
| 'aria-valuenow': 150, | ||
| 'aria-valuemax': 400, | ||
| }, | ||
| play: async ({ canvas, step }) => { | ||
| const handle = canvas.getByRole('separator'); | ||
|
|
||
| await step('Has aria-orientation="horizontal" for bottom position', async () => { | ||
| expect(handle).toHaveAttribute('aria-orientation', 'horizontal'); | ||
| }); | ||
|
|
||
| await step('Shows on the top of the parent element', async () => { | ||
| handle.focus(); | ||
| const parentRect = handle.parentElement?.getBoundingClientRect(); | ||
| const handleRect = handle.getBoundingClientRect(); | ||
| expect(handleRect.top).toBeLessThan(parentRect?.top ?? 0); | ||
| }); | ||
| }, | ||
| }; | ||
|
|
||
| export const PositionTop: Story = { | ||
| name: 'Position: top', | ||
| args: { | ||
| position: 'top', | ||
| 'aria-label': 'Top panel resize handle', | ||
| 'aria-valuenow': 150, | ||
| 'aria-valuemax': 400, | ||
| }, | ||
| play: async ({ canvas, step }) => { | ||
| const handle = canvas.getByRole('separator'); | ||
|
|
||
| await step('Has aria-orientation="horizontal" for top position', async () => { | ||
| expect(handle).toHaveAttribute('aria-orientation', 'horizontal'); | ||
| }); | ||
|
|
||
| await step('Shows on the bottom of the parent element', async () => { | ||
| handle.focus(); | ||
| const parentRect = handle.parentElement?.getBoundingClientRect(); | ||
| const handleRect = handle.getBoundingClientRect(); | ||
| expect(handleRect.top).toBeGreaterThan(parentRect?.top ?? 0); | ||
| }); | ||
| }, | ||
| }; | ||
|
|
||
| export const AriaRole: Story = { | ||
| name: 'ARIA: role separator', | ||
| args: { | ||
| position: 'left', | ||
| 'aria-label': 'Sidebar resize handle', | ||
| 'aria-valuenow': 240, | ||
| 'aria-valuemax': 480, | ||
| }, | ||
| play: async ({ canvas, step }) => { | ||
| await step('Has role="separator"', async () => { | ||
| const handle = canvas.getByRole('separator'); | ||
| expect(handle).toBeInTheDocument(); | ||
| }); | ||
| }, | ||
| }; | ||
|
|
||
| export const AriaOrientationVertical: Story = { | ||
| name: 'ARIA: orientation vertical', | ||
| args: { | ||
| position: 'left', | ||
| 'aria-label': 'Sidebar resize handle', | ||
| 'aria-valuenow': 240, | ||
| 'aria-valuemax': 480, | ||
| }, | ||
| play: async ({ canvas, step }) => { | ||
| await step('Has aria-orientation="vertical" for left position', async () => { | ||
| const handle = canvas.getByRole('separator'); | ||
| expect(handle).toHaveAttribute('aria-orientation', 'vertical'); | ||
| }); | ||
| }, | ||
| }; | ||
|
|
||
| export const AriaOrientationHorizontal: Story = { | ||
| name: 'ARIA: orientation horizontal', | ||
| args: { | ||
| position: 'bottom', | ||
| 'aria-label': 'Bottom panel resize handle', | ||
| 'aria-valuenow': 150, | ||
| 'aria-valuemax': 400, | ||
| }, | ||
| play: async ({ canvas, step }) => { | ||
| await step('Has aria-orientation="horizontal" for bottom position', async () => { | ||
| const handle = canvas.getByRole('separator'); | ||
| expect(handle).toHaveAttribute('aria-orientation', 'horizontal'); | ||
| }); | ||
| }, | ||
| }; | ||
|
|
||
| export const AriaLabel: Story = { | ||
| name: 'ARIA: aria-label', | ||
| args: { | ||
| position: 'bottom', | ||
| 'aria-label': 'Specific resize handle label', | ||
| 'aria-valuenow': 150, | ||
| 'aria-valuemax': 400, | ||
| }, | ||
| play: async ({ canvas, step }) => { | ||
| await step('Has correct aria-label', async () => { | ||
| const handle = canvas.getByRole('separator'); | ||
| expect(handle).toHaveAttribute('aria-label', 'Specific resize handle label'); | ||
| }); | ||
| }, | ||
| }; | ||
|
|
||
| export const AriaValue: Story = { | ||
| name: 'ARIA: aria-value* attributes', | ||
| args: { | ||
| position: 'bottom', | ||
| 'aria-label': 'Specific resize handle label', | ||
| 'aria-valuenow': 150, | ||
| 'aria-valuemax': 400, | ||
| }, | ||
| play: async ({ canvas, step }) => { | ||
| await step('Has correct aria-value* attributes', async () => { | ||
| const handle = canvas.getByRole('separator'); | ||
| expect(handle).toHaveAttribute('aria-valuemin', '0'); | ||
| expect(handle).toHaveAttribute('aria-valuenow', '150'); | ||
| expect(handle).toHaveAttribute('aria-valuemax', '400'); | ||
| }); | ||
| }, | ||
| }; | ||
|
|
||
| export const FocusTooltipVertical: Story = { | ||
| name: 'Keyboard: vertical focus tooltip', | ||
| args: { | ||
| position: 'left', | ||
| 'aria-label': 'Sidebar resize handle', | ||
| 'aria-valuenow': 200, | ||
| 'aria-valuemax': 500, | ||
| }, | ||
| play: async ({ canvas, step }) => { | ||
| const handle = canvas.getByRole('separator'); | ||
|
|
||
| await step('Tab onto the handle', async () => { | ||
| await userEvent.tab(); | ||
| expect(handle).toHaveFocus(); | ||
| }); | ||
|
|
||
| await step('Tooltip with ← → hint is visible', async () => { | ||
| // The tooltip is rendered in a portal outside canvas. | ||
| const tooltip = await within(document.body).findByText('← → to resize'); | ||
| expect(tooltip).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| await step('Tooltip disappears on blur', async () => { | ||
| handle.blur(); | ||
| // Give the tooltip time to un-mount / fade out. | ||
| await new Promise((r) => setTimeout(r, 250)); | ||
| const tooltip = within(document.body).queryByText('← → to resize'); | ||
| expect(tooltip).not.toBeInTheDocument(); | ||
| }); | ||
| }, | ||
| }; | ||
|
|
||
| export const FocusTooltipHorizontal: Story = { | ||
| name: 'Keyboard: horizontal focus tooltip', | ||
| args: { | ||
| position: 'bottom', | ||
| 'aria-label': 'Bottom panel resize handle', | ||
| 'aria-valuenow': 150, | ||
| 'aria-valuemax': 400, | ||
| }, | ||
| play: async ({ canvas, step }) => { | ||
| const handle = canvas.getByRole('separator'); | ||
|
|
||
| await step('Tab onto the handle', async () => { | ||
| await userEvent.tab(); | ||
| expect(handle).toHaveFocus(); | ||
| }); | ||
|
|
||
| await step('Tooltip with ↑ ↓ hint is visible', async () => { | ||
| const tooltip = await within(document.body).findByText('↑ ↓ to resize'); | ||
| expect(tooltip).toBeInTheDocument(); | ||
| }); | ||
| }, | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.