From e7fbca0bb0a062f84b5eb72b172bd29cb8518bcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B3=E5=BB=B7=E5=AE=89?= <73953029+nrps9909@users.noreply.github.com> Date: Thu, 27 Aug 2026 05:27:07 +0800 Subject: [PATCH] fix: make hidden overflow items inert --- src/Item.tsx | 6 +++++- tests/__snapshots__/ssr.spec.tsx.snap | 1 + tests/responsive.spec.tsx | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Item.tsx b/src/Item.tsx index cfd18bd..c09bdc9 100644 --- a/src/Item.tsx +++ b/src/Item.tsx @@ -82,9 +82,13 @@ function InternalItem( }; } - const overflowProps: React.HTMLAttributes = {}; + const overflowProps: Omit, 'inert'> & { + inert?: boolean | ''; + } = {}; if (mergedHidden) { overflowProps['aria-hidden'] = true; + // React <= 18 only serializes unknown boolean attributes when passed as strings. + overflowProps.inert = Number.parseInt(React.version, 10) >= 19 ? true : ''; } let itemNode = ( diff --git a/tests/__snapshots__/ssr.spec.tsx.snap b/tests/__snapshots__/ssr.spec.tsx.snap index e5415e9..00b42a6 100644 --- a/tests/__snapshots__/ssr.spec.tsx.snap +++ b/tests/__snapshots__/ssr.spec.tsx.snap @@ -19,6 +19,7 @@ exports[`Overflow.SSR basic 1`] = `