Skip to content

Commit 0145978

Browse files
authored
fix(MessageBox): screen reader reads out whole content of MessageBox when opened (#1504)
1 parent 18854b6 commit 0145978

File tree

10 files changed

+299
-234
lines changed

10 files changed

+299
-234
lines changed

packages/main/src/components/ActionSheet/ActionSheet.stories.mdx

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,6 @@ import { DocsCommonProps } from '@shared/stories/DocsCommonProps';
4040

4141
<br />
4242

43-
### Opening ActionSheets
44-
45-
`ActionSheets` can only be opened by attaching a `ref` to the component and then call the corresponding **`open`** method. The method receives the target element - _on which the `ActionSheet` is to be opened_ - as parameter.
46-
47-
```JSX
48-
const ActionSheetComponent = () => {
49-
const actionSheetRef = useRef();
50-
const onButtonClick = (e) => {
51-
actionSheetRef.current.open(e.target);
52-
};
53-
return (
54-
<>
55-
<Button onClick={onButtonClick}>Open ActionSheet</Button>
56-
<ActionSheet ref={actionSheetRef}>
57-
<Button icon="add">Accept</Button>
58-
<Button>Reject</Button>
59-
<Button>This is my super long text!</Button>
60-
</ActionSheet>
61-
</>
62-
);
63-
};
64-
```
65-
66-
<br />
67-
6843
## Example
6944

7045
<Canvas>
@@ -95,6 +70,40 @@ const ActionSheetComponent = () => {
9570

9671
<ArgsTable story="." />
9772

73+
## Methods
74+
75+
This component exposes public methods. You can invoke them directly on the instance of the component, e.g. by using React Refs.
76+
77+
| Name | Parameters | Description |
78+
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
79+
| **close** | &mdash; | Closes the popover/dialog. |
80+
| **open** | <dl><dt className="methodText">**opener**</dt><dd className="methodText">the element that the popover is opened by</dd><dd><code>HTMLElement</code></dd></dl> | Opens popover on desktop and dialog on mobile. |
81+
| **applyFocus** | &mdash; | Focuses the element denoted by <code>initialFocus</code>, if provided, or the first focusable element otherwise. |
82+
| **isOpen** | &mdash; |
83+
84+
## Opening ActionSheets
85+
86+
`ActionSheets` can only be opened by attaching a `ref` to the component and then call the corresponding **`open`** method. The method receives the target element - _on which the `ActionSheet` is to be opened_ - as parameter.
87+
88+
```JSX
89+
const ActionSheetComponent = () => {
90+
const actionSheetRef = useRef();
91+
const onButtonClick = (e) => {
92+
actionSheetRef.current.open(e.target);
93+
};
94+
return (
95+
<>
96+
<Button onClick={onButtonClick}>Open ActionSheet</Button>
97+
<ActionSheet ref={actionSheetRef}>
98+
<Button icon="add">Accept</Button>
99+
<Button>Reject</Button>
100+
<Button>This is my super long text!</Button>
101+
</ActionSheet>
102+
</>
103+
);
104+
};
105+
```
106+
98107
## Using ActionSheets inside other components
99108

100109
`ActionSheets` are often used within other components, when opened this could sometimes have unwanted side effects.

packages/main/src/components/MessageBox/MessageBox.stories.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ import { createSelectArgTypes } from '@shared/stories/createSelectArgTypes';
5252

5353
<ArgsTable story="." />
5454

55+
## Methods
56+
57+
This component exposes public methods. You can invoke them directly on the instance of the component, e.g. by using React Refs.
58+
59+
| Name | Parameters | Description |
60+
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | --- |
61+
| **applyFocus** | &mdash; | Focuses the element denoted by <code>initialFocus</code>, if provided, or the first focusable element otherwise. |
62+
| **close** | &mdash; | Hides the block layer (for modal popups only) |
63+
| **isOpen** | &mdash; | Override this method to provide custom logic for the popup's open/closed state. Maps to the "opened" property by default. |
64+
| **open** | <dl><dt className="methodText">**preventInitialFocus**</dt><dd className="methodText">prevents applying the focus inside the popup</dd><dd><code>boolean</code></dd></dl> | Shows the block layer (for modal popups only) and sets the correct z-index for the purpose of popup stacking | |
65+
5566
## Opening and Closing MessageBoxes
5667

5768
Unlike `Popovers` or `Dialogs`, `MessageBoxes` do not need to be provided with a `ref` to be opened or closed. Instead, the `open` prop can be used for this.

0 commit comments

Comments
 (0)