-
Notifications
You must be signed in to change notification settings - Fork 12
Add modal launcher details to docs #2875
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
Changes from all commits
ee1b57b
1dbac8a
684802c
657d698
9d29c92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| --- | ||
| --- |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ import packageConfig from "../../packages/wonder-blocks-modal/package.json"; | |
| import ComponentInfo from "../components/component-info"; | ||
| import modalPanelArgtypes from "./modal-panel.argtypes"; | ||
| import {allModes} from "../../.storybook/modes"; | ||
| import {focusStyles} from "@khanacademy/wonder-blocks-styles"; | ||
|
|
||
| const longBody = ( | ||
| <View style={{gap: sizing.size_160}}> | ||
|
|
@@ -135,7 +136,10 @@ export const Default: StoryComponentType = { | |
| <ModalPanel | ||
| {...args} | ||
| content={ | ||
| <View style={styles.content}> | ||
| <View | ||
| style={[styles.content, styles.scrollContainer]} | ||
| tabIndex={0} | ||
| > | ||
| <Heading size="xxlarge" id="modal-title-0"> | ||
| Modal Title | ||
| </Heading> | ||
|
|
@@ -165,7 +169,11 @@ export const WithHeader: StoryComponentType = { | |
| header={ | ||
| <ModalHeader titleId="modal-title-2" title="Modal Title" /> | ||
| } | ||
| content={longBody} | ||
| content={ | ||
| <View tabIndex={0} style={styles.scrollContainer}> | ||
| {longBody} | ||
| </View> | ||
| } | ||
| /> | ||
| </ModalDialog> | ||
| ), | ||
|
|
@@ -186,7 +194,10 @@ export const WithFooter: StoryComponentType = { | |
| <ModalDialog aria-labelledby="modal-title-3" style={styles.dialog}> | ||
| <ModalPanel | ||
| content={ | ||
| <View style={styles.content}> | ||
| <View | ||
| style={[styles.content, styles.scrollContainer]} | ||
| tabIndex={0} | ||
| > | ||
| <Heading size="xxlarge" id="modal-title-3"> | ||
| Modal Title | ||
| </Heading> | ||
|
|
@@ -303,6 +314,18 @@ export const WithStyle: StoryComponentType = { | |
| borderRadius: 20, | ||
| } as const; | ||
|
|
||
| const button = ( | ||
| <BodyText style={{display: "flex"}}> | ||
| <Button | ||
| style={{ | ||
| marginInlineStart: "auto", | ||
| marginBlockStart: sizing.size_100, | ||
| }} | ||
| > | ||
| A button | ||
| </Button> | ||
| </BodyText> | ||
| ); | ||
| return ( | ||
| <ModalDialog aria-labelledby="modal-title-1" style={styles.dialog}> | ||
| <ModalPanel | ||
|
|
@@ -312,7 +335,12 @@ export const WithStyle: StoryComponentType = { | |
| title="Modal Title" | ||
| /> | ||
| } | ||
| content={longBody} | ||
| content={ | ||
| <> | ||
| {longBody} | ||
| {button} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there is scrollable content in a modal and no interactive elements within it (like the original example without the button), should we add tabIndex=0 to the scrollable container, similar to what's done in I'm wondering if there are valid use cases where there might not be an interactive element within the scrollable modal content that would prevent scrolling via keyboard! What do you think?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made some updates to ensure scrollability with the keyboard on those internal I will add that I don't love wrapping an internal What I'd love to see is some dynamic keyboard scroll handling so consumers don't have to manually add
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's an issue for it: https://khanacademy.atlassian.net/browse/FEI-7356
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for creating a ticket! I agree that this would probably need a broader solution! The keyboard scrolling issue is also related to the SimpleTable a11y fixes I'm working on in https://github.com/Khan/frontend/pull/5786
FWIW, Chrome + Firefox on macOS will automatically make a scrollable div focusable! Safari does not 😢 https://jsfiddle.net/qorx1a5b/3/ |
||
| </> | ||
| } | ||
| style={modalStyles} | ||
| /> | ||
| </ModalDialog> | ||
|
|
@@ -352,4 +380,7 @@ const styles = StyleSheet.create({ | |
| content: { | ||
| gap: sizing.size_240, | ||
| }, | ||
| scrollContainer: { | ||
| ":focus-visible": focusStyles.focus[":focus-visible"], | ||
| }, | ||
| }); | ||
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.
Does this mean the heading should always be in the
titleprop? Are there use cases that consumers would need where it is part of thecontent?I was assuming manually configuring
aria-labelledbymeant a custom implementation of the title was needed, since using thetitleprop will auto-wire up the attributes already!wonder-blocks/packages/wonder-blocks-modal/src/components/flexible-dialog.tsx
Lines 143 to 152 in 7065e96
I also noticed that the
aria-labelledbyprop provided by the consumer doesn't end up getting used (other aria attributes are applied though!). This might be what was causing an issue with the original example?wonder-blocks/packages/wonder-blocks-modal/src/components/flexible-dialog.tsx
Lines 159 to 161 in 7065e96
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.
The component is intended to use the
titleprop so naming can be handled automatically, with the option for it to be inserted intocontentwith thetitlerender prop. But the story originally included anaria-labelledbyexample that didn't work properly, and it was a little confusing outside of the happy path. I opened a separate ticket to revisit naming witharia-labelledby, since it's a little more involved than fixing up some stories: https://khanacademy.atlassian.net/browse/WB-2168