-
Notifications
You must be signed in to change notification settings - Fork 1
🎨 Palette: Dashboard Accessibility and Shortcut Enhancement #213
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
Open
ruhdevops
wants to merge
1
commit into
main
Choose a base branch
from
palette-dashboard-ux-enhancement-12508629615568804500
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,53 @@ | ||
| const { chromium } = require('playwright-core'); | ||
|
|
||
| (async () => { | ||
| const browser = await chromium.launch({ executablePath: '/usr/bin/google-chrome' }); | ||
| const page = await browser.newPage(); | ||
| await page.goto('http://localhost:8000'); | ||
|
|
||
| console.log('Testing accessibility attributes...'); | ||
| const btn = await page.$('#dashboardBtn'); | ||
| const ariaControls = await btn.getAttribute('aria-controls'); | ||
| const ariaExpanded = await btn.getAttribute('aria-expanded'); | ||
| const title = await btn.getAttribute('title'); | ||
|
|
||
| console.log('aria-controls:', ariaControls); | ||
| console.log('aria-expanded:', ariaExpanded); | ||
| console.log('title:', title); | ||
|
|
||
| if (ariaControls !== 'dashboardModal' || ariaExpanded !== 'false' || title !== 'Dashboard (D)') { | ||
| console.error('FAILED accessibility check'); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| console.log('Testing keyboard shortcut D to open...'); | ||
| await page.keyboard.press('d'); | ||
| const ariaExpandedOpen = await btn.getAttribute('aria-expanded'); | ||
| console.log('aria-expanded (open):', ariaExpandedOpen); | ||
| if (ariaExpandedOpen !== 'true') { | ||
| console.error('FAILED keyboard open'); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| console.log('Testing keyboard shortcut D to close...'); | ||
| await page.keyboard.press('d'); | ||
| const ariaExpandedClosed = await btn.getAttribute('aria-expanded'); | ||
| console.log('aria-expanded (closed):', ariaExpandedClosed); | ||
| if (ariaExpandedClosed !== 'false') { | ||
| console.error('FAILED keyboard close'); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| console.log('Testing Escape key to close...'); | ||
| await page.keyboard.press('d'); | ||
| await page.keyboard.press('Escape'); | ||
| const ariaExpandedEsc = await btn.getAttribute('aria-expanded'); | ||
| console.log('aria-expanded (esc):', ariaExpandedEsc); | ||
| if (ariaExpandedEsc !== 'false') { | ||
| console.error('FAILED escape close'); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| console.log('ALL MANUAL CHECKS PASSED'); | ||
| await browser.close(); | ||
| })(); |
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,41 @@ | ||
| import asyncio | ||
| from playwright.async_api import async_playwright | ||
|
|
||
| async def main(): | ||
| async with async_playwright() as p: | ||
| browser = await p.chromium.launch() | ||
| page = await browser.new_page() | ||
| page.on("console", lambda msg: print(f"BROWSER CONSOLE: {msg.text}")) | ||
|
|
||
| await page.goto('http://localhost:8000') | ||
| await asyncio.sleep(2) | ||
|
|
||
| btn = page.locator('#dashboardBtn') | ||
|
|
||
| print('Testing click to open...') | ||
| await btn.click() | ||
| await asyncio.sleep(1) | ||
| aria_expanded_open = await btn.get_attribute('aria-expanded') | ||
| print(f'aria-expanded (open) after click: {aria_expanded_open}') | ||
|
|
||
| if aria_expanded_open == 'true': | ||
| await page.screenshot(path="/home/jules/verification/dashboard_open_click.png") | ||
| print("Successfully opened dashboard via click") | ||
| else: | ||
| print("Failed to open dashboard via click") | ||
|
|
||
| print('Testing keyboard shortcut d...') | ||
| # Close it first if open | ||
| if aria_expanded_open == 'true': | ||
| await page.keyboard.press('Escape') | ||
| await asyncio.sleep(1) | ||
|
|
||
| await page.keyboard.press('d') | ||
| await asyncio.sleep(1) | ||
| aria_expanded_d = await btn.get_attribute('aria-expanded') | ||
| print(f'aria-expanded after d: {aria_expanded_d}') | ||
|
|
||
| await browser.close() | ||
|
|
||
| if __name__ == '__main__': | ||
| asyncio.run(main()) |
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,67 @@ | ||
| import { test, expect } from '@playwright/test'; | ||
|
|
||
| test.describe('Dashboard UX Enhancement', () => { | ||
| test.beforeEach(async ({ page }) => { | ||
| // Point to the local index.html using the local server | ||
| await page.goto('http://localhost:8000'); | ||
| }); | ||
|
|
||
| test('Dashboard button has correct accessibility attributes', async ({ page }) => { | ||
| const dashboardBtn = page.locator('#dashboardBtn'); | ||
| await expect(dashboardBtn).toHaveAttribute('aria-controls', 'dashboardModal'); | ||
| await expect(dashboardBtn).toHaveAttribute('aria-expanded', 'false'); | ||
| await expect(dashboardBtn).toHaveAttribute('title', 'Dashboard (D)'); | ||
| }); | ||
|
|
||
| test('Dashboard toggles via button click', async ({ page }) => { | ||
| const dashboardBtn = page.locator('#dashboardBtn'); | ||
| const dashboardModal = page.locator('#dashboardModal'); | ||
|
|
||
| // Initially closed | ||
| await expect(dashboardModal).not.toBeVisible(); | ||
| await expect(dashboardBtn).toHaveAttribute('aria-expanded', 'false'); | ||
|
|
||
| // Click to open | ||
| await dashboardBtn.click(); | ||
|
|
||
| // Check if dashboard is visible. | ||
| // Note: Side panels might be display: block but off-screen. | ||
| // However, app.js sets display to 'block' and aria-hidden to 'false'. | ||
| await expect(dashboardModal).toHaveAttribute('aria-hidden', 'false'); | ||
| await expect(dashboardBtn).toHaveAttribute('aria-expanded', 'true'); | ||
|
|
||
| // Close via close button in panel | ||
| const closeBtn = page.locator('#closeDashboard'); | ||
| await closeBtn.click(); | ||
| await expect(dashboardBtn).toHaveAttribute('aria-expanded', 'false'); | ||
| }); | ||
|
|
||
| test('Dashboard toggles via keyboard shortcut D', async ({ page }) => { | ||
| const dashboardBtn = page.locator('#dashboardBtn'); | ||
| const dashboardModal = page.locator('#dashboardModal'); | ||
|
|
||
| // Initially closed | ||
| await expect(dashboardBtn).toHaveAttribute('aria-expanded', 'false'); | ||
|
|
||
| // Press 'd' to open | ||
| await page.keyboard.press('d'); | ||
| await expect(dashboardBtn).toHaveAttribute('aria-expanded', 'true'); | ||
| await expect(dashboardModal).toHaveAttribute('aria-hidden', 'false'); | ||
|
|
||
| // Press 'd' again to close | ||
| await page.keyboard.press('d'); | ||
| await expect(dashboardBtn).toHaveAttribute('aria-expanded', 'false'); | ||
| }); | ||
|
|
||
| test('Dashboard closes via Escape key', async ({ page }) => { | ||
| const dashboardBtn = page.locator('#dashboardBtn'); | ||
|
|
||
| // Open it | ||
| await page.keyboard.press('d'); | ||
| await expect(dashboardBtn).toHaveAttribute('aria-expanded', 'true'); | ||
|
|
||
| // Press Escape | ||
| await page.keyboard.press('Escape'); | ||
| await expect(dashboardBtn).toHaveAttribute('aria-expanded', 'false'); | ||
| }); | ||
| }); |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When focus is anywhere except an input/textarea, this treats every key event whose key is
das the dashboard toggle, including Ctrl+D/Cmd+D that users use to bookmark the page. In that scenario the dashboard opens or closes unexpectedly while the browser bookmark shortcut is invoked; checke.ctrlKey/e.metaKey/e.altKeybefore handling the new global shortcut.Useful? React with 👍 / 👎.