Skip to content

Commit 0254b82

Browse files
committed
refactor: use findFirstFocusable instead of custom hasFocusableContent
1 parent ec43c45 commit 0254b82

1 file changed

Lines changed: 1 addition & 8 deletions

File tree

  • packages/react-components/react-popover/library/src/components/Popover

packages/react-components/react-popover/library/src/components/Popover/usePopover.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export const usePopover_unstable = (props: PopoverProps): PopoverState => {
191191

192192
const contentElement = positioningRefs.contentRef.current;
193193

194-
if (!contentElement || hasFocusableContent(contentElement)) {
194+
if (!contentElement || findFirstFocusable(contentElement)) {
195195
return;
196196
}
197197

@@ -230,13 +230,6 @@ export const usePopover_unstable = (props: PopoverProps): PopoverState => {
230230
};
231231
};
232232

233-
function hasFocusableContent(contentElement: HTMLElement): boolean {
234-
const focusableSelector =
235-
'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
236-
237-
return contentElement.matches(focusableSelector) || contentElement.querySelector(focusableSelector) !== null;
238-
}
239-
240233
/**
241234
* Creates and manages the Popover open state
242235
*/

0 commit comments

Comments
 (0)