Skip to content

Commit 0bfd52a

Browse files
ktaborsdannifysnowystinger
authored
Improved dialog a11y at 400% zoom (#2630)
* 2571 adjsuting css for improved dialog a11y * making sure the hero image has rounded top corners with scrolling at 400% * fixing footer and buttongroup at 400% zoom * lint fixes * Update packages/@react-spectrum/dialog/stories/Dialog.stories.tsx * fixing content, footer, and buttongroup placement in Firefox * moving footer and buttongroup to different lines in dialog zoom * moving some of the a11y css to also help mobile views with footers and buttongroups Co-authored-by: Danni <[email protected]> Co-authored-by: Robert Snow <[email protected]>
1 parent 3366ae3 commit 0bfd52a

File tree

2 files changed

+83
-1
lines changed

2 files changed

+83
-1
lines changed

packages/@adobe/spectrum-css-temp/components/dialog/index.css

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,14 @@ governing permissions and limitations under the License.
339339
justify-content: flex-start;
340340
}
341341

342+
.spectrum-Dialog-footer {
343+
min-width: fit-content;
344+
}
345+
346+
.spectrum-Dialog-buttonGroup {
347+
min-width: 0;
348+
}
349+
342350
.spectrum-Dialog--fullscreen,
343351
.spectrum-Dialog--fullscreenTakeover {
344352

@@ -365,3 +373,35 @@ governing permissions and limitations under the License.
365373
}
366374
}
367375
}
376+
377+
/* additional a11y support by moveing scrolling from content to dialog */
378+
@media screen and (max-height: 400px) {
379+
.spectrum-Dialog .spectrum-Dialog-grid {
380+
border-top-left-radius: var(--spectrum-dialog-border-radius);
381+
border-top-right-radius: var(--spectrum-dialog-border-radius);
382+
overflow-y: auto;
383+
384+
grid-template-columns: var(--spectrum-dialog-padding-x) auto 1fr auto minmax(0, auto) var(--spectrum-dialog-padding-x);
385+
grid-template-rows: auto var(--spectrum-dialog-padding-y) auto auto auto 1fr auto auto var(--spectrum-dialog-padding-y);
386+
grid-template-areas:
387+
"hero hero hero hero hero hero"
388+
". . . . . ."
389+
". heading heading heading typeIcon ."
390+
". header header header header ."
391+
". divider divider divider divider ."
392+
". content content content content ."
393+
". footer footer footer footer ."
394+
". buttonGroup buttonGroup buttonGroup buttonGroup ."
395+
". . . . . .";
396+
}
397+
398+
.spectrum-Dialog-content {
399+
overflow-y: visible;
400+
height: min-content;
401+
display: inline-table;
402+
}
403+
404+
.spectrum-Dialog-footer + .spectrum-Dialog-buttonGroup {
405+
padding-block-start: calc(var(--spectrum-global-dimension-size-25) * 2);
406+
}
407+
}

packages/@react-spectrum/dialog/stories/Dialog.stories.tsx

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {Heading, Text} from '@react-spectrum/text';
2323
import {Image} from '@react-spectrum/image';
2424
import {Item, Picker} from '@react-spectrum/picker';
2525
import {Radio, RadioGroup} from '@react-spectrum/radio';
26-
import React from 'react';
26+
import React, {useState} from 'react';
2727
import {SpectrumAlertDialogProps} from '@react-types/dialog';
2828
import {storiesOf} from '@storybook/react';
2929
import {TextField} from '@react-spectrum/textfield';
@@ -82,6 +82,10 @@ storiesOf('Dialog', module)
8282
'three buttons, vertical orientation',
8383
() => renderWithThreeButtonsVertical({})
8484
)
85+
.add(
86+
'three buttons, footer',
87+
() => <RenderWithThreeButtonsAndFooter />
88+
)
8589
.add(
8690
'cleared content',
8791
() => renderWithDividerInContent({})
@@ -480,6 +484,44 @@ function renderWithThreeButtonsVertical({width = 'auto', ...props}) {
480484
);
481485
}
482486

487+
function RenderWithThreeButtonsAndFooter({width = 'auto', ...props}) {
488+
let labels = [
489+
{
490+
checkboxLabel: 'I have read and accept',
491+
secondaryButtonLabel: 'Secondary',
492+
primaryButtonLabel: 'Primary'
493+
}, {
494+
checkboxLabel: 'I have read and accept the terms of use and privacy policy',
495+
secondaryButtonLabel: 'Secondary and best button',
496+
primaryButtonLabel: 'Primary and worst'
497+
}
498+
];
499+
let [whichLabels, setWhichLabels] = useState(0);
500+
501+
return (
502+
<div style={{display: 'flex', width, margin: '100px 0'}}>
503+
<Button variant="primary" onPress={() => {whichLabels ? setWhichLabels(0) : setWhichLabels(1);}}>Toggle labels</Button>
504+
<DialogTrigger defaultOpen>
505+
<ActionButton>Trigger</ActionButton>
506+
{(close) => (
507+
<Dialog {...props}>
508+
<Heading>The Heading</Heading>
509+
<Header>The Header</Header>
510+
<Divider />
511+
<Content>{singleParagraph()}</Content>
512+
<Footer><Checkbox>{labels[whichLabels].checkboxLabel}</Checkbox></Footer>
513+
<ButtonGroup>
514+
<Button variant="secondary" onPress={close}>{labels[whichLabels].secondaryButtonLabel}</Button>
515+
<Button variant="primary" onPress={close}>{labels[whichLabels].primaryButtonLabel}</Button>
516+
<Button variant="cta" onPress={close} autoFocus>CTA</Button>
517+
</ButtonGroup>
518+
</Dialog>
519+
)}
520+
</DialogTrigger>
521+
</div>
522+
);
523+
}
524+
483525
function renderWithDividerInContent({width = 'auto', ...props}) {
484526
return (
485527
<div style={{display: 'flex', width, margin: '100px 0'}}>

0 commit comments

Comments
 (0)