|
10 | 10 | * governing permissions and limitations under the License.
|
11 | 11 | */
|
12 | 12 |
|
13 |
| -import {Button, Dialog, DialogTrigger, Heading, Modal, ModalOverlay} from 'react-aria-components'; |
| 13 | +import {Button, ComboBox, Dialog, DialogTrigger, Heading, Input, Label, ListBox, Modal, ModalOverlay, Popover, TextField} from 'react-aria-components'; |
14 | 14 | import {Meta, StoryFn} from '@storybook/react';
|
15 | 15 | import React, {useEffect} from 'react';
|
16 | 16 | import './styles.css';
|
| 17 | +import {MyListBoxItem} from './utils'; |
| 18 | +import styles from '../example/index.css'; |
| 19 | + |
17 | 20 |
|
18 | 21 | export default {
|
19 | 22 | title: 'React Aria Components/Modal',
|
@@ -188,3 +191,83 @@ export const ModalInteractionOutsideDefaultOverlayExample: ModalStory = () => {
|
188 | 191 | </DialogTrigger>
|
189 | 192 | );
|
190 | 193 | };
|
| 194 | + |
| 195 | +function InertTest() { |
| 196 | + return ( |
| 197 | + <DialogTrigger> |
| 198 | + <Button>Open modal</Button> |
| 199 | + <ModalOverlay |
| 200 | + isDismissable |
| 201 | + style={{ |
| 202 | + position: 'fixed', |
| 203 | + zIndex: 100, |
| 204 | + top: 0, |
| 205 | + left: 0, |
| 206 | + bottom: 0, |
| 207 | + right: 0, |
| 208 | + background: 'rgba(0, 0, 0, 0.5)', |
| 209 | + display: 'flex', |
| 210 | + alignItems: 'center', |
| 211 | + justifyContent: 'center' |
| 212 | + }}> |
| 213 | + <Modal |
| 214 | + style={{ |
| 215 | + background: 'Canvas', |
| 216 | + color: 'CanvasText', |
| 217 | + border: '1px solid gray', |
| 218 | + padding: 30 |
| 219 | + }}> |
| 220 | + <Dialog> |
| 221 | + {() => ( |
| 222 | + <> |
| 223 | + <TextField> |
| 224 | + <Label>First name</Label> |
| 225 | + <Input /> |
| 226 | + </TextField> |
| 227 | + <DialogTrigger> |
| 228 | + <Button>Combobox Trigger</Button> |
| 229 | + <Popover placement="bottom start"> |
| 230 | + <Dialog> |
| 231 | + {() => ( |
| 232 | + <ComboBox |
| 233 | + menuTrigger="focus" |
| 234 | + autoFocus |
| 235 | + name="combo-box-example" |
| 236 | + data-testid="combo-box-example" |
| 237 | + allowsEmptyCollection> |
| 238 | + <Label style={{display: 'block'}}>Test</Label> |
| 239 | + <div style={{display: 'flex'}}> |
| 240 | + <Input /> |
| 241 | + <Button> |
| 242 | + <span aria-hidden="true" style={{padding: '0 2px'}}>▼</span> |
| 243 | + </Button> |
| 244 | + </div> |
| 245 | + <ListBox |
| 246 | + className={styles.menu}> |
| 247 | + <MyListBoxItem>Foo</MyListBoxItem> |
| 248 | + <MyListBoxItem>Bar</MyListBoxItem> |
| 249 | + <MyListBoxItem>Baz</MyListBoxItem> |
| 250 | + <MyListBoxItem href="http://google.com">Google</MyListBoxItem> |
| 251 | + </ListBox> |
| 252 | + </ComboBox> |
| 253 | + )} |
| 254 | + </Dialog> |
| 255 | + </Popover> |
| 256 | + </DialogTrigger> |
| 257 | + </> |
| 258 | + )} |
| 259 | + </Dialog> |
| 260 | + </Modal> |
| 261 | + </ModalOverlay> |
| 262 | + </DialogTrigger> |
| 263 | + ); |
| 264 | +} |
| 265 | + |
| 266 | +export const InertTestStory = { |
| 267 | + render: () => <InertTest />, |
| 268 | + parameters: { |
| 269 | + description: { |
| 270 | + data: 'You should be able to click "Combobox Trigger" and then click on the textfield, closing the subdialog. A second click should move focus into the textfield' |
| 271 | + } |
| 272 | + } |
| 273 | +}; |
0 commit comments