Improve focus management for AxoContextMenu

This commit is contained in:
trevor-signal
2026-01-08 16:19:51 -05:00
committed by GitHub
parent 928dfbd6bf
commit b6f9c17bea

View File

@@ -232,6 +232,7 @@ export namespace AxoContextMenu {
* Uses a portal to render the content part into the `body`.
*/
export const Content: FC<ContentProps> = memo(props => {
const { open } = useStrictContext(RootContext);
return (
<ContextMenu.Portal>
<ContextMenu.Content
@@ -239,6 +240,8 @@ export namespace AxoContextMenu {
alignOffset={-6}
collisionPadding={6}
onCloseAutoFocus={props.onCloseAutoFocus}
// @ts-expect-error -- React/TS doesn't know about inert
inert={open ? undefined : 'true'}
>
{props.children}
</ContextMenu.Content>