Skip to content
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

fix: issue with autofocus for drawer #2555

Merged
merged 9 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 9 additions & 11 deletions packages/components/src/components/drawer/drawer.lite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,15 @@ export default function DBDrawer(props: DBDrawerProps) {
<div class="db-drawer-header-text">
<Slot name="drawerHeader" />
</div>
<Show when={props.withCloseButton}>
<DBButton
className="button-close-drawer"
id={props.closeButtonId}
icon="cross"
variant="ghost"
noText
onClick={() => state.handleClose('close')}>
{props.closeButtonText ?? DEFAULT_CLOSE_BUTTON}
</DBButton>
</Show>
<DBButton
className="button-close-drawer"
id={props.closeButtonId}
icon="cross"
variant="ghost"
noText
onClick={() => state.handleClose('close')}>
{props.closeButtonText ?? DEFAULT_CLOSE_BUTTON}
</DBButton>
</header>
<div class="db-drawer-content">{props.children}</div>
</article>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const testAction = () => {
test(`should open and close drawer`, async ({ mount, page }) => {
let test: string = '';
const drawer: any = (
<DBDrawer onClose={() => (test = 'close')} withCloseButton={true}>
<DBDrawer onClose={() => (test = 'close')}>
<span data-testid="test">Test</span>
</DBDrawer>
);
Expand Down
5 changes: 0 additions & 5 deletions packages/components/src/components/drawer/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ export interface DBDrawerDefaultProps {
* The "end" depends on which direction you use.
*/
rounded?: boolean;

/**
* The withCloseButton attribute shows/hides the default close button.
*/
withCloseButton?: boolean;
}

export type DBDrawerProps = DBDrawerDefaultProps &
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export default function DBHeader(props: DBHeaderProps) {
<DBDrawer
className="db-header-drawer"
rounded
withCloseButton
spacing="small"
open={props.drawerOpen}
onClose={() => state.toggle()}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
>
<db-drawer
[backdrop]="exampleProps?.backdrop"
[withCloseButton]="exampleProps?.withCloseButton"
[rounded]="exampleProps?.rounded"
[width]="exampleProps?.width"
[spacing]="exampleProps?.spacing"
Expand Down
2 changes: 0 additions & 2 deletions showcases/react-showcase/src/components/drawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const getDrawer = ({
id,
width,
rounded,
withCloseButton,
spacing,
openDrawer,
setOpenDrawer,
Expand All @@ -24,7 +23,6 @@ const getDrawer = ({
}: DBDrawerProps & AdditionalDrawerProperties) => (
<div>
<DBDrawer
withCloseButton={withCloseButton}
rounded={rounded}
width={width}
spacing={spacing}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["web dialog Close Button button article","Functional"]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["unknown. dialog. document. clickable, Close Button, button. dialog. button, Close Button","Functional"]
5 changes: 4 additions & 1 deletion showcases/screen-reader/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ const translations: Record<string, string[]> = {
checked: ['aktiviert'],
' of ': [' von '],
clickable: ['anklickbar'],
'has auto complete': ['mit Auto Vervollständigung']
'has auto complete': ['mit Auto Vervollständigung'],
unknown: ['Unbekannt'],
dialog: ['Dialogfeld'],
document: ['Dokument']
};

const cleanSpeakInstructions = (phraseLog: string[]): string[] =>
Expand Down
16 changes: 16 additions & 0 deletions showcases/screen-reader/tests/drawer.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { getTest, testDefault } from '../default';

const test = getTest();

test.describe('DBDrawer', () => {
testDefault({
test,
title: 'should autofocus',
url: './#/01/drawer?page=density',
async testFn(voiceOver, nvda) {
const screenReader = voiceOver ?? nvda;
await screenReader?.act();
await screenReader?.next();
}
});
});
19 changes: 0 additions & 19 deletions showcases/shared/drawer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"name": "Functional",
"className": "db-density-functional",
"props": {
"withCloseButton": true,
"open": "open",
"onClose": "toggleDrawer(false)"
}
Expand All @@ -15,7 +14,6 @@
"name": "(Default) Regular",
"className": "db-density-regular",
"props": {
"withCloseButton": true,
"open": "open",
"onClose": "toggleDrawer(false)"
}
Expand All @@ -24,7 +22,6 @@
"name": "Expressive",
"className": "db-density-expressive",
"props": {
"withCloseButton": true,
"open": "open",
"onClose": "toggleDrawer(false)"
}
Expand All @@ -37,15 +34,13 @@
{
"name": "(Default) Medium",
"props": {
"withCloseButton": true,
"open": "open",
"onClose": "toggleDrawer(false)"
}
},
{
"name": "Full",
"props": {
"withCloseButton": true,
"width": "full",
"open": "open",
"onClose": "toggleDrawer(false)"
Expand All @@ -59,15 +54,13 @@
{
"name": "(Default) No rounding",
"props": {
"withCloseButton": true,
"open": "open",
"onClose": "toggleDrawer(false)"
}
},
{
"name": "Rounded",
"props": {
"withCloseButton": true,
"rounded": true,
"open": "open",
"onClose": "toggleDrawer(false)"
Expand All @@ -81,15 +74,13 @@
{
"name": "(Default) Medium",
"props": {
"withCloseButton": true,
"open": "open",
"onClose": "toggleDrawer(false)"
}
},
{
"name": "Small",
"props": {
"withCloseButton": true,
"spacing": "small",
"open": "open",
"onClose": "toggleDrawer(false)"
Expand All @@ -98,7 +89,6 @@
{
"name": "Large",
"props": {
"withCloseButton": true,
"spacing": "large",
"open": "open",
"onClose": "toggleDrawer(false)"
Expand All @@ -107,7 +97,6 @@
{
"name": "No spacing",
"props": {
"withCloseButton": true,
"spacing": "none",
"open": "open",
"onClose": "toggleDrawer(false)"
Expand All @@ -121,15 +110,13 @@
{
"name": "(Default) With Backdrop",
"props": {
"withCloseButton": true,
"open": "open",
"onClose": "toggleDrawer(false)"
}
},
{
"name": "Backdrop-weak",
"props": {
"withCloseButton": true,
"backdrop": "weak",
"open": "open",
"onClose": "toggleDrawer(false)"
Expand All @@ -138,7 +125,6 @@
{
"name": "Invisible",
"props": {
"withCloseButton": true,
"backdrop": "invisible",
"open": "open",
"onClose": "toggleDrawer(false)"
Expand All @@ -147,7 +133,6 @@
{
"name": "No Backdrop",
"props": {
"withCloseButton": true,
"backdrop": "none",
"open": "open",
"onClose": "toggleDrawer(false)"
Expand All @@ -161,15 +146,13 @@
{
"name": "(Default) Right",
"props": {
"withCloseButton": true,
"open": "open",
"onClose": "toggleDrawer(false)"
}
},
{
"name": "Left",
"props": {
"withCloseButton": true,
"direction": "left",
"open": "open",
"onClose": "toggleDrawer(false)"
Expand All @@ -178,7 +161,6 @@
{
"name": "Up",
"props": {
"withCloseButton": true,
"direction": "up",
"open": "open",
"onClose": "toggleDrawer(false)"
Expand All @@ -187,7 +169,6 @@
{
"name": "Down",
"props": {
"withCloseButton": true,
"direction": "down",
"open": "open",
"onClose": "toggleDrawer(false)"
Expand Down
1 change: 0 additions & 1 deletion showcases/vue-showcase/src/components/drawer/Drawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const toggleDrawer = (example?: string) => {
>
<DBDrawer
:backdrop="exampleProps?.backdrop"
:withCloseButton="exampleProps?.withCloseButton"
:rounded="exampleProps?.rounded"
:width="exampleProps?.width"
:spacing="exampleProps?.spacing"
Expand Down
Loading