✨(frontend) fix toggle panel button a11y with dynamic label
improves screen sr by updating label and state indication dynamically Signed-off-by: Cyril <c.gromoff@gmail.com>
This commit is contained in:
@@ -10,6 +10,7 @@ and this project adheres to
|
|||||||
|
|
||||||
- ♿(frontend) improve accessibility:
|
- ♿(frontend) improve accessibility:
|
||||||
- ♿(frontend) add skip to content button for keyboard accessibility #1624
|
- ♿(frontend) add skip to content button for keyboard accessibility #1624
|
||||||
|
- ♿(frontend) fix toggle panel button a11y labels #1634
|
||||||
- ⚡️(frontend) Enhance/html copy to download #1669
|
- ⚡️(frontend) Enhance/html copy to download #1669
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
@@ -23,8 +24,6 @@ and this project adheres to
|
|||||||
- ✨ Add comments feature to the editor #1330
|
- ✨ Add comments feature to the editor #1330
|
||||||
- ✨(backend) Comments on text editor #1330
|
- ✨(backend) Comments on text editor #1330
|
||||||
- ✨(frontend) link to create new doc #1574
|
- ✨(frontend) link to create new doc #1574
|
||||||
- ♿(frontend) improve accessibility:
|
|
||||||
- ♿(frontend) add skip to content button for keyboard accessibility #1624
|
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { expect, test } from '@playwright/test';
|
import { expect, test } from '@playwright/test';
|
||||||
|
|
||||||
import { createDoc, mockedListDocs } from './utils-common';
|
import { createDoc, mockedListDocs, toggleHeaderMenu } from './utils-common';
|
||||||
import { createRootSubPage } from './utils-sub-pages';
|
import { createRootSubPage } from './utils-sub-pages';
|
||||||
|
|
||||||
test.describe('Doc grid dnd', () => {
|
test.describe('Doc grid dnd', () => {
|
||||||
@@ -185,10 +185,7 @@ test.describe('Doc grid dnd mobile', () => {
|
|||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
await page
|
await toggleHeaderMenu(page);
|
||||||
.getByRole('button', { name: 'Open the header menu' })
|
|
||||||
.getByText('menu')
|
|
||||||
.click();
|
|
||||||
|
|
||||||
await expect(page.locator('.--docs-sub-page-item').first()).toHaveAttribute(
|
await expect(page.locator('.--docs-sub-page-item').first()).toHaveAttribute(
|
||||||
'draggable',
|
'draggable',
|
||||||
|
|||||||
@@ -83,6 +83,34 @@ export const randomName = (name: string, browserName: string, length: number) =>
|
|||||||
return `${browserName}-${Math.floor(Math.random() * 10000)}-${index}-${name}`;
|
return `${browserName}-${Math.floor(Math.random() * 10000)}-${index}-${name}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const openHeaderMenu = async (page: Page) => {
|
||||||
|
const toggleButton = page.getByTestId('header-menu-toggle');
|
||||||
|
await expect(toggleButton).toBeVisible();
|
||||||
|
|
||||||
|
const isExpanded =
|
||||||
|
(await toggleButton.getAttribute('aria-expanded')) === 'true';
|
||||||
|
if (!isExpanded) {
|
||||||
|
await toggleButton.click();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const closeHeaderMenu = async (page: Page) => {
|
||||||
|
const toggleButton = page.getByTestId('header-menu-toggle');
|
||||||
|
await expect(toggleButton).toBeVisible();
|
||||||
|
|
||||||
|
const isExpanded =
|
||||||
|
(await toggleButton.getAttribute('aria-expanded')) === 'true';
|
||||||
|
if (isExpanded) {
|
||||||
|
await toggleButton.click();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const toggleHeaderMenu = async (page: Page) => {
|
||||||
|
const toggleButton = page.getByTestId('header-menu-toggle');
|
||||||
|
await expect(toggleButton).toBeVisible();
|
||||||
|
await toggleButton.click();
|
||||||
|
};
|
||||||
|
|
||||||
export const createDoc = async (
|
export const createDoc = async (
|
||||||
page: Page,
|
page: Page,
|
||||||
docName: string,
|
docName: string,
|
||||||
@@ -94,10 +122,7 @@ export const createDoc = async (
|
|||||||
|
|
||||||
for (let i = 0; i < randomDocs.length; i++) {
|
for (let i = 0; i < randomDocs.length; i++) {
|
||||||
if (isMobile) {
|
if (isMobile) {
|
||||||
await page
|
await openHeaderMenu(page);
|
||||||
.getByRole('button', { name: 'Open the header menu' })
|
|
||||||
.getByText('menu')
|
|
||||||
.click();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await page
|
await page
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import { Page, expect } from '@playwright/test';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
BrowserName,
|
BrowserName,
|
||||||
|
closeHeaderMenu,
|
||||||
|
openHeaderMenu,
|
||||||
randomName,
|
randomName,
|
||||||
updateDocTitle,
|
updateDocTitle,
|
||||||
verifyDocName,
|
verifyDocName,
|
||||||
@@ -15,10 +17,7 @@ export const createRootSubPage = async (
|
|||||||
isMobile = false,
|
isMobile = false,
|
||||||
) => {
|
) => {
|
||||||
if (isMobile) {
|
if (isMobile) {
|
||||||
await page
|
await openHeaderMenu(page);
|
||||||
.getByRole('button', { name: 'Open the header menu' })
|
|
||||||
.getByText('menu')
|
|
||||||
.click();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get response
|
// Get response
|
||||||
@@ -29,10 +28,7 @@ export const createRootSubPage = async (
|
|||||||
const subPageJson = (await response.json()) as { id: string };
|
const subPageJson = (await response.json()) as { id: string };
|
||||||
|
|
||||||
if (isMobile) {
|
if (isMobile) {
|
||||||
await page
|
await openHeaderMenu(page);
|
||||||
.getByRole('button', { name: 'Open the header menu' })
|
|
||||||
.getByText('menu')
|
|
||||||
.click();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get doc tree
|
// Get doc tree
|
||||||
@@ -44,13 +40,9 @@ export const createRootSubPage = async (
|
|||||||
.getByTestId(`doc-sub-page-item-${subPageJson.id}`)
|
.getByTestId(`doc-sub-page-item-${subPageJson.id}`)
|
||||||
.first();
|
.first();
|
||||||
await expect(subPageItem).toBeVisible();
|
await expect(subPageItem).toBeVisible();
|
||||||
await subPageItem.click();
|
|
||||||
|
|
||||||
if (isMobile) {
|
if (isMobile) {
|
||||||
await page
|
await closeHeaderMenu(page);
|
||||||
.getByRole('button', { name: 'Open the header menu' })
|
|
||||||
.getByText('close')
|
|
||||||
.click();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update sub page name
|
// Update sub page name
|
||||||
|
|||||||
@@ -12,12 +12,16 @@ export const ButtonTogglePanel = () => {
|
|||||||
<Button
|
<Button
|
||||||
size="medium"
|
size="medium"
|
||||||
onClick={() => togglePanel()}
|
onClick={() => togglePanel()}
|
||||||
aria-label={t('Open the header menu')}
|
aria-label={t(
|
||||||
|
isPanelOpen ? 'Close the header menu' : 'Open the header menu',
|
||||||
|
)}
|
||||||
|
aria-expanded={isPanelOpen}
|
||||||
variant="tertiary"
|
variant="tertiary"
|
||||||
icon={
|
icon={
|
||||||
<Icon $withThemeInherited iconName={isPanelOpen ? 'close' : 'menu'} />
|
<Icon $withThemeInherited iconName={isPanelOpen ? 'close' : 'menu'} />
|
||||||
}
|
}
|
||||||
className="--docs--button-toggle-panel"
|
className="--docs--button-toggle-panel"
|
||||||
|
data-testid="header-menu-toggle"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user