Skip to content

Commit 155e361

Browse files
authored
fix: check for element visibility should take react aria attribute into consideration (#8642)
* fix: check for element visibility should take react aria attribute into consideration * remove log * deleted too much
1 parent f4f8a44 commit 155e361

File tree

2 files changed

+52
-3
lines changed

2 files changed

+52
-3
lines changed

packages/@react-aria/utils/src/isElementVisible.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ function isAttributeVisible(element: Element, childElement?: Element) {
6363
*/
6464
export function isElementVisible(element: Element, childElement?: Element): boolean {
6565
if (supportsCheckVisibility) {
66-
return element.checkVisibility();
66+
return element.checkVisibility() && !element.closest('[data-react-aria-prevent-focus]');
6767
}
68-
68+
6969
return (
7070
element.nodeName !== '#comment' &&
7171
isStyleVisible(element) &&

packages/react-aria-components/stories/Toolbar.stories.tsx

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13-
import {Checkbox, Link, ToggleButton, Toolbar, ToolbarProps} from 'react-aria-components';
13+
import {Button, Checkbox, Group, Label, Link, ListBox, Popover, Select, SelectValue, Separator, ToggleButton, Toolbar, ToolbarProps} from 'react-aria-components';
1414
import {classNames} from '@react-spectrum/utils';
1515
import {Meta, StoryObj} from '@storybook/react';
16+
import {MyListBoxItem} from './utils';
1617
import {Orientation} from 'react-stately';
1718
import React from 'react';
1819
import styles from '../example/index.css';
@@ -56,3 +57,51 @@ export const ToolbarExample: ToolbarStory = {
5657
);
5758
}
5859
};
60+
61+
export const SelectSupport: ToolbarStory = {
62+
args: {
63+
orientation: 'horizontal' as Orientation
64+
},
65+
render: (props: ToolbarProps) => {
66+
return (
67+
<Toolbar {...props} aria-label="Text formatting">
68+
<Group aria-label="Style">
69+
<ToggleButton aria-label="Bold">
70+
<b>B</b>
71+
</ToggleButton>
72+
<ToggleButton aria-label="Italic">
73+
<i>I</i>
74+
</ToggleButton>
75+
<ToggleButton aria-label="Underline">
76+
<u>U</u>
77+
</ToggleButton>
78+
</Group>
79+
<Separator orientation="vertical" />
80+
<Select>
81+
<Label>Favorite Animal</Label>
82+
<Button>
83+
<SelectValue />
84+
<span aria-hidden="true"></span>
85+
</Button>
86+
<Popover>
87+
<ListBox>
88+
<MyListBoxItem>Aardvark</MyListBoxItem>
89+
<MyListBoxItem>Cat</MyListBoxItem>
90+
<MyListBoxItem>Dog</MyListBoxItem>
91+
<MyListBoxItem>Kangaroo</MyListBoxItem>
92+
<MyListBoxItem>Panda</MyListBoxItem>
93+
<MyListBoxItem>Snake</MyListBoxItem>
94+
</ListBox>
95+
</Popover>
96+
</Select>
97+
<Separator orientation="vertical" />
98+
99+
<Group aria-label="Clipboard">
100+
<Button>Copy</Button>
101+
<Button>Paste</Button>
102+
<Button>Cut</Button>
103+
</Group>
104+
</Toolbar>
105+
);
106+
}
107+
};

0 commit comments

Comments
 (0)