Skip to content

Commit 8562995

Browse files
committed
refactor: addressed comments, updated docs
1 parent c4c2e94 commit 8562995

4 files changed

Lines changed: 10 additions & 5 deletions

File tree

docs/6.x/docs/components/Dialog/Dialog.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ const MyComponent = () => {
4040
onDismiss={hideDialog}
4141
title="Alert"
4242
content="This is simple dialog"
43-
actions={[{ label: 'Done', onPress: hideDialog }]}
43+
actions={[
44+
<Button key='done-btn' onPress={hideDialog}>Done</Button>
45+
]}
4446
/>
4547
</Portal>
4648
</View>

docs/src/data/componentDocs6x.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5206,10 +5206,10 @@
52065206
"Dialog/Dialog": {
52075207
"filepath": "Dialog/Dialog.tsx",
52085208
"title": "Dialog",
5209-
"description": "Dialogs inform users about a specific task and may contain critical information, require decisions, or involve multiple tasks.\nTo render the `Dialog` above other components, you'll need to wrap it with the [`Portal`](../Portal) component.\n\n## Usage\n```js\nimport * as React from 'react';\nimport { View } from 'react-native';\nimport { Button, Dialog, Portal, PaperProvider } from 'react-native-paper';\n\nconst MyComponent = () => {\n const [visible, setVisible] = React.useState(false);\n\n const showDialog = () => setVisible(true);\n\n const hideDialog = () => setVisible(false);\n\n return (\n <PaperProvider>\n <View>\n <Button onPress={showDialog}>Show Dialog</Button>\n <Portal>\n <Dialog\n visible={visible}\n onDismiss={hideDialog}\n title=\"Alert\"\n content=\"This is simple dialog\"\n actions={[{ label: 'Done', onPress: hideDialog }]}\n />\n </Portal>\n </View>\n </PaperProvider>\n );\n};\n\nexport default MyComponent;\n```",
5209+
"description": "Dialogs inform users about a specific task and may contain critical information, require decisions, or involve multiple tasks.\nTo render the `Dialog` above other components, you'll need to wrap it with the [`Portal`](../Portal) component.\n\n## Usage\n```js\nimport * as React from 'react';\nimport { View } from 'react-native';\nimport { Button, Dialog, Portal, PaperProvider } from 'react-native-paper';\n\nconst MyComponent = () => {\n const [visible, setVisible] = React.useState(false);\n\n const showDialog = () => setVisible(true);\n\n const hideDialog = () => setVisible(false);\n\n return (\n <PaperProvider>\n <View>\n <Button onPress={showDialog}>Show Dialog</Button>\n <Portal>\n <Dialog\n visible={visible}\n onDismiss={hideDialog}\n title=\"Alert\"\n content=\"This is simple dialog\"\n actions={[\n\t\t\t\t\t\t \t\t<Button key='done-btn' onPress={hideDialog}>Done</Button>\n\t\t\t\t\t\t ]}\n />\n </Portal>\n </View>\n </PaperProvider>\n );\n};\n\nexport default MyComponent;\n```",
52105210
"link": "dialog",
52115211
"data": {
5212-
"description": "Dialogs inform users about a specific task and may contain critical information, require decisions, or involve multiple tasks.\nTo render the `Dialog` above other components, you'll need to wrap it with the [`Portal`](../Portal) component.\n\n## Usage\n```js\nimport * as React from 'react';\nimport { View } from 'react-native';\nimport { Button, Dialog, Portal, PaperProvider } from 'react-native-paper';\n\nconst MyComponent = () => {\n const [visible, setVisible] = React.useState(false);\n\n const showDialog = () => setVisible(true);\n\n const hideDialog = () => setVisible(false);\n\n return (\n <PaperProvider>\n <View>\n <Button onPress={showDialog}>Show Dialog</Button>\n <Portal>\n <Dialog\n visible={visible}\n onDismiss={hideDialog}\n title=\"Alert\"\n content=\"This is simple dialog\"\n actions={[{ label: 'Done', onPress: hideDialog }]}\n />\n </Portal>\n </View>\n </PaperProvider>\n );\n};\n\nexport default MyComponent;\n```",
5212+
"description": "Dialogs inform users about a specific task and may contain critical information, require decisions, or involve multiple tasks.\nTo render the `Dialog` above other components, you'll need to wrap it with the [`Portal`](../Portal) component.\n\n## Usage\n```js\nimport * as React from 'react';\nimport { View } from 'react-native';\nimport { Button, Dialog, Portal, PaperProvider } from 'react-native-paper';\n\nconst MyComponent = () => {\n const [visible, setVisible] = React.useState(false);\n\n const showDialog = () => setVisible(true);\n\n const hideDialog = () => setVisible(false);\n\n return (\n <PaperProvider>\n <View>\n <Button onPress={showDialog}>Show Dialog</Button>\n <Portal>\n <Dialog\n visible={visible}\n onDismiss={hideDialog}\n title=\"Alert\"\n content=\"This is simple dialog\"\n actions={[\n\t\t\t\t\t\t \t\t<Button key='done-btn' onPress={hideDialog}>Done</Button>\n\t\t\t\t\t\t ]}\n />\n </Portal>\n </View>\n </PaperProvider>\n );\n};\n\nexport default MyComponent;\n```",
52135213
"displayName": "Dialog",
52145214
"methods": [],
52155215
"statics": [],

src/components/Dialog/Dialog.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ export type Props = {
111111
* onDismiss={hideDialog}
112112
* title="Alert"
113113
* content="This is simple dialog"
114-
* actions={[{ label: 'Done', onPress: hideDialog }]}
114+
* actions={[
115+
* <Button key='done-btn' onPress={hideDialog}>Done</Button>
116+
* ]}
115117
* />
116118
* </Portal>
117119
* </View>
@@ -175,7 +177,7 @@ const Dialog = ({
175177
]}
176178
theme={theme}
177179
testID={testID}
178-
aria-label={typeof title === 'string' ? title : ariaLabel}
180+
aria-label={ariaLabel ?? (typeof title === 'string' ? title : undefined)}
179181
>
180182
{icon ? <DialogIcon icon={icon} /> : null}
181183

src/components/Modal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ function Modal({
226226
style={[{ opacity }, styles.content, contentContainerStyle]}
227227
container
228228
aria-label={ariaLabel}
229+
role="dialog"
229230
>
230231
{children}
231232
</Surface>

0 commit comments

Comments
 (0)