Compare commits
No files matched your search
@@ -107,7 +107,7 @@ Core regression + correctness pass. Cover all sub-angles:
|
||||
forwarding/merging, context registration cleanup, nested component coordination,
|
||||
portals, focus management, keyboard navigation, ARIA attributes, disabled/read-only
|
||||
states, form integration, SSR/hydration safety, Strict Mode behavior, shadow
|
||||
DOM-safe DOM access (`contains`, `getTarget`, `activeElement`, `ownerDocument`,
|
||||
DOM-safe DOM access (`closest`, `contains`, `getTarget`, `activeElement`, `ownerDocument`,
|
||||
`ownerWindow`).
|
||||
- **Removed-behavior auditor.** For every line diff DELETES or replaces, name
|
||||
invariant/behavior it enforced, then search new code for where invariant
|
||||
|
||||
@@ -23,6 +23,10 @@ default-job: &default-job
|
||||
description: The version of react to be used
|
||||
type: string
|
||||
default: << pipeline.parameters.react-version >>
|
||||
package-overrides:
|
||||
description: Space separated package@version overrides applied after install
|
||||
type: string
|
||||
default: ''
|
||||
resource_class: medium
|
||||
environment:
|
||||
&default-environment # expose it globally otherwise we have to thread it from each job to the install command
|
||||
@@ -54,6 +58,7 @@ jobs:
|
||||
- checkout
|
||||
- code-infra/install-deps:
|
||||
react-version: << parameters.react-version >>
|
||||
package-overrides: << parameters.package-overrides >>
|
||||
- run:
|
||||
name: Run tests on JSDOM
|
||||
command: pnpm test:jsdom
|
||||
@@ -91,6 +96,7 @@ jobs:
|
||||
- checkout
|
||||
- code-infra/install-deps:
|
||||
react-version: << parameters.react-version >>
|
||||
package-overrides: << parameters.package-overrides >>
|
||||
- run:
|
||||
name: Tests TypeScript definitions
|
||||
command: pnpm typescript
|
||||
@@ -136,6 +142,7 @@ jobs:
|
||||
- checkout
|
||||
- code-infra/install-deps:
|
||||
react-version: << parameters.react-version >>
|
||||
package-overrides: << parameters.package-overrides >>
|
||||
- run:
|
||||
name: Run tests on headless Chromium
|
||||
command: pnpm test:chromium
|
||||
@@ -318,14 +325,20 @@ workflows:
|
||||
<<: *default-context
|
||||
name: 'JSDOM tests (React 18)'
|
||||
react-version: '^18'
|
||||
# react-router 8 requires React >= 19.2.7
|
||||
package-overrides: react-router@7
|
||||
- test_browser:
|
||||
<<: *default-context
|
||||
name: 'Browser tests (React 18)'
|
||||
react-version: '^18'
|
||||
# react-router 8 requires React >= 19.2.7
|
||||
package-overrides: react-router@7
|
||||
- test_types:
|
||||
<<: *default-context
|
||||
name: 'Typechecking (React 18)'
|
||||
react-version: '^18'
|
||||
# react-router 8 requires React >= 19.2.7
|
||||
package-overrides: react-router@7
|
||||
typescript-next:
|
||||
triggers:
|
||||
- schedule:
|
||||
|
||||
+13
-13
@@ -20,18 +20,18 @@ jobs:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- name: Set up pnpm
|
||||
uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
|
||||
uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
|
||||
- name: Use Node.js 22.x
|
||||
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
|
||||
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||
with:
|
||||
node-version: '22.23.2'
|
||||
cache: 'pnpm' # https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-dependencies
|
||||
- run: pnpm install
|
||||
- run: pnpm release:build
|
||||
- name: Publish packages
|
||||
uses: mui/mui-public/.github/actions/ci-publish@0534c1cc1a7f0f170d927199ec407192a656e81f # master
|
||||
uses: mui/mui-public/.github/actions/ci-publish@b296c98bc17f685db974504d2c00094a59d1698d # master
|
||||
with:
|
||||
pr-comment: true
|
||||
|
||||
@@ -42,11 +42,11 @@ jobs:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- name: Set up pnpm
|
||||
uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
|
||||
uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
|
||||
- name: Use Node.js 22.x
|
||||
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
|
||||
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||
with:
|
||||
node-version: '22.23.2'
|
||||
cache: 'pnpm' # https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-dependencies
|
||||
@@ -56,7 +56,7 @@ jobs:
|
||||
run: |
|
||||
VERSION=$(node -p "(require('./package.json').config && require('./package.json').config.valeVersion) || ''")
|
||||
echo "vale_version=$VERSION" >> $GITHUB_OUTPUT
|
||||
- uses: vale-cli/vale-action@85f9f7f2c5f449ac0ae5b66662961bae3f77ca6a # v2.1.2
|
||||
- uses: vale-cli/vale-action@518a9136acc6e6668ce7c00d367051e0941e87ff # v3.0.0
|
||||
continue-on-error: true # GitHub Action flag needed until https://github.com/errata-ai/vale-action/issues/89 is fixed
|
||||
with:
|
||||
version: ${{ steps.vale-version.outputs.vale_version }}
|
||||
@@ -75,11 +75,11 @@ jobs:
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- name: Set up pnpm
|
||||
uses: pnpm/action-setup@8912a9102ac27614460f54aedde9e1e7f9aec20d # v6.0.5
|
||||
uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
|
||||
- name: Use Node.js 22.x
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
||||
with:
|
||||
node-version: '22.23.2'
|
||||
cache: 'pnpm'
|
||||
@@ -95,9 +95,9 @@ jobs:
|
||||
if: ${{ github.repository_owner == 'mui' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- name: Prepare for publishing
|
||||
uses: mui/mui-public/.github/actions/publish-prepare@0534c1cc1a7f0f170d927199ec407192a656e81f # master
|
||||
uses: mui/mui-public/.github/actions/publish-prepare@b296c98bc17f685db974504d2c00094a59d1698d # master
|
||||
with:
|
||||
node-version: '22.23.2'
|
||||
- name: Dry run npm publishing
|
||||
|
||||
@@ -13,7 +13,7 @@ permissions: {}
|
||||
|
||||
jobs:
|
||||
claude-review:
|
||||
uses: mui/mui-public/.github/workflows/claude-review.yml@0534c1cc1a7f0f170d927199ec407192a656e81f # master
|
||||
uses: mui/mui-public/.github/workflows/claude-review.yml@b296c98bc17f685db974504d2c00094a59d1698d # master
|
||||
permissions:
|
||||
contents: read # read the repo (checkout + git diff)
|
||||
id-token: write # mint the GitHub OIDC token exchanged for a Claude token via WIF
|
||||
|
||||
@@ -16,10 +16,10 @@ jobs:
|
||||
security-events: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@ff2f1c621b7f889edc0d3c761ac2e6a3f8cdb0dd # v4.37.7
|
||||
uses: github/codeql-action/init@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4.38.0
|
||||
with:
|
||||
languages: typescript
|
||||
config-file: ./.github/codeql/codeql-config.yml
|
||||
@@ -30,4 +30,4 @@ jobs:
|
||||
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
||||
# queries: security-extended,security-and-quality
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@ff2f1c621b7f889edc0d3c761ac2e6a3f8cdb0dd # v4.37.7
|
||||
uses: github/codeql-action/analyze@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4.38.0
|
||||
@@ -9,7 +9,7 @@ permissions: {}
|
||||
jobs:
|
||||
issue_cleanup:
|
||||
name: Clean issue body
|
||||
uses: mui/mui-public/.github/workflows/issues_body-cleanup.yml@0534c1cc1a7f0f170d927199ec407192a656e81f # master
|
||||
uses: mui/mui-public/.github/workflows/issues_body-cleanup.yml@b296c98bc17f685db974504d2c00094a59d1698d # master
|
||||
permissions:
|
||||
contents: read
|
||||
issues: write
|
||||
@@ -35,12 +35,12 @@ jobs:
|
||||
name: npm-publish
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
ref: ${{ inputs.sha }}
|
||||
fetch-depth: 0 # Fetch full history for proper git operations
|
||||
- name: Prepare for publishing
|
||||
uses: mui/mui-public/.github/actions/publish-prepare@0534c1cc1a7f0f170d927199ec407192a656e81f # master
|
||||
uses: mui/mui-public/.github/actions/publish-prepare@b296c98bc17f685db974504d2c00094a59d1698d # master
|
||||
with:
|
||||
node-version: '22.23.2'
|
||||
- name: Publish packages
|
||||
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
actions: read
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Run analysis
|
||||
@@ -40,6 +40,6 @@ jobs:
|
||||
publish_results: true
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: Upload to code-scanning
|
||||
uses: github/codeql-action/upload-sarif@ff2f1c621b7f889edc0d3c761ac2e6a3f8cdb0dd # v4.37.7
|
||||
uses: github/codeql-action/upload-sarif@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4.38.0
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
@@ -21,7 +21,7 @@ This repository contains the source code and documentation for Base UI: a headl
|
||||
- Always use the `useTimeout` utility from `@base-ui/utils/useTimeout` instead of `window.setTimeout`, and `useAnimationFrame` from `@base-ui/utils/useAnimationFrame` instead of `requestAnimationFrame`. Search for other example usage in the codebase if unsure how to use them.
|
||||
- Use the `useStableCallback` utility from `@base-ui/utils/useStableCallback` instead of `React.useCallback` if the function is called within an effect or event handler. The utility cannot be used to memoize functions that are called directly in the body of a component (during render), so continue with `React.useCallback` in those scenarios.
|
||||
- Always use the `useIsoLayoutEffect` utility from `@base-ui/utils/useIsoLayoutEffect` instead of `React.useLayoutEffect`.
|
||||
- Always use the shadow DOM-safe utilities for DOM traversal and event targeting: `contains`, `getTarget`, and `activeElement`. Always use the owner utilities `ownerDocument` and `ownerWindow` instead of global `document`/`window` lookups when the code is tied to a DOM node, including realm-sensitive checks such as `instanceof`.
|
||||
- Always use the shadow DOM-safe utilities for DOM traversal and event targeting: `closest`, `contains`, `getTarget`, and `activeElement`. Always use the owner utilities `ownerDocument` and `ownerWindow` instead of global `document`/`window` lookups when the code is tied to a DOM node, including realm-sensitive checks such as `instanceof`.
|
||||
- Avoid duplicating logic where necessary. If two components can share logic (such as event handlers), define the logic/handlers in the parent and share it through a context to the child; use the existing context if it exists.
|
||||
|
||||
## Styling
|
||||
@@ -44,6 +44,7 @@ This repository contains the source code and documentation for Base UI: a headl
|
||||
- Run tests in Chromium env with `pnpm test:chromium {name} --no-watch` such as `pnpm test:chromium NumberField --no-watch` or `pnpm test:chromium parse --no-watch`.
|
||||
- Do not call `await flushMicrotasks()` directly after `await render(...)` when there are no interactions or state changes between them; `render` is already awaited, so that immediate flush is unnecessary.
|
||||
- Do not group multiple `expect()` assertions in a single `waitFor()` callback. Use one assertion per `waitFor()` so retries are scoped to the specific condition that may change asynchronously.
|
||||
- For locale-formatted text, use `expect(element.textContent).toBe(expected)` with the expected value formatted using the same locale and options as the component. When the component uses the runtime default locale, derive expectations using that default too (for example, `new Intl.NumberFormat(undefined, options)`); do not hardcode `en-US` or US-formatted strings in expected values. Pin a locale only when testing locale-specific behavior, and use it consistently for both the component and expectations. `toHaveTextContent` normalizes nonbreaking spaces in the rendered text but not in the expected string, causing failures in locales such as `pt-BR`.
|
||||
- Use `firePointer` from `#test-utils` instead of `fireEvent.pointer*` whenever a test depends on event timing. `fireEvent` silently drops `timeStamp`, so the event inherits the environment's clock — the real one in a browser — and gesture velocity then depends on how long the runner took between calls. A lint rule enforces this.
|
||||
- If you made changes to the source code, ensure you verify your changes by running tests (see above), and writing new tests where applicable. If tests require the browser because, for example, they require layout measurements, restrict it to the Chromium env by using `it.skipIf(isJSDOM)` or `describe.skipIf(isJSDOM)` (search other tests for example usage if unsure).
|
||||
- Follow the established conventions in existing tests. Each file/component is tested with the filename `name.test.tsx`. For example, `PopoverRoot.test.tsx` is next to its source file `PopoverRoot.tsx`.
|
||||
|
||||
+19
-19
@@ -20,62 +20,62 @@
|
||||
"@base-ui/utils": "workspace:*",
|
||||
"@mdx-js/loader": "^3.1.1",
|
||||
"@mdx-js/react": "^3.1.1",
|
||||
"@mui/internal-docs-infra": "0.12.1-canary.42",
|
||||
"@next/mdx": "^16.3.1",
|
||||
"@mui/internal-docs-infra": "0.12.1-canary.48",
|
||||
"@next/mdx": "^16.3.4",
|
||||
"@react-spring/web": "^10.1.2",
|
||||
"@stefanprobst/rehype-extract-toc": "^3.0.0",
|
||||
"@tanstack/react-form": "^1.33.4",
|
||||
"@tanstack/react-virtual": "^3.14.9",
|
||||
"@tanstack/react-form": "^1.33.5",
|
||||
"@tanstack/react-virtual": "^3.14.11",
|
||||
"@types/mdx": "^2.0.14",
|
||||
"clipboard-copy": "^4.0.1",
|
||||
"clsx": "^2.1.1",
|
||||
"es-toolkit": "^1.50.0",
|
||||
"es-toolkit": "^1.52.0",
|
||||
"estree-util-value-to-estree": "^3.5.0",
|
||||
"globby": "^16.2.3",
|
||||
"globby": "^16.2.4",
|
||||
"hast": "^1.0.0",
|
||||
"hast-util-heading-rank": "^3.0.0",
|
||||
"hast-util-to-string": "^3.0.1",
|
||||
"lucide-react": "^1.31.0",
|
||||
"lucide-react": "^1.42.0",
|
||||
"lz-string": "^1.5.0",
|
||||
"match-sorter": "^8.3.0",
|
||||
"next": "16.3.1",
|
||||
"postcss": "^8.5.26",
|
||||
"next": "16.3.4",
|
||||
"postcss": "^8.5.28",
|
||||
"postcss-custom-media": "^12.0.1",
|
||||
"postcss-import": "^16.1.1",
|
||||
"radix-ui": "^1.4.3",
|
||||
"postcss-import": "^17.0.0",
|
||||
"radix-ui": "^1.6.7",
|
||||
"react": "^19.2.8",
|
||||
"react-dom": "^19.2.8",
|
||||
"react-error-boundary": "6.1.2",
|
||||
"react-hook-form": "^7.75.0",
|
||||
"react-error-boundary": "6.1.5",
|
||||
"react-hook-form": "^7.87.0",
|
||||
"remark-gfm": "^4.0.1",
|
||||
"remark-parse": "^11.0.0",
|
||||
"remark-rehype": "^11.1.2",
|
||||
"remark-typography": "0.7.3",
|
||||
"remark-typography": "0.8.5",
|
||||
"scroll-into-view-if-needed": "3.1.0",
|
||||
"server-only": "^0.0.1",
|
||||
"unist-util-visit-parents": "^6.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@mdx-js/mdx": "3.1.1",
|
||||
"@tailwindcss/postcss": "4.2.4",
|
||||
"@tailwindcss/postcss": "4.3.3",
|
||||
"@types/gtag.js": "0.0.20",
|
||||
"@types/hast": "3.0.5",
|
||||
"@types/node": "22.20.1",
|
||||
"@types/react": "19.2.18",
|
||||
"@types/react-dom": "19.2.4",
|
||||
"@types/react-dom": "19.2.7",
|
||||
"@types/unist": "3.0.3",
|
||||
"cross-env": "10.1.0",
|
||||
"mdast-util-mdx-jsx": "3.2.0",
|
||||
"motion": "12.43.0",
|
||||
"motion": "13.2.0",
|
||||
"prettier": "3.9.6",
|
||||
"remark-parse": "11.0.0",
|
||||
"remark-stringify": "11.0.0",
|
||||
"rimraf": "6.1.3",
|
||||
"serve": "14.2.6",
|
||||
"tailwindcss": "4.2.4",
|
||||
"tailwindcss": "4.3.3",
|
||||
"typescript": "npm:@typescript/typescript6@6.0.2",
|
||||
"unified": "11.0.5",
|
||||
"unist-util-visit": "5.1.0",
|
||||
"zod": "4.4.3"
|
||||
"zod": "4.5.4"
|
||||
}
|
||||
}
|
||||
@@ -973,10 +973,11 @@ Renders a \`<button>\` element.
|
||||
|
||||
**Trigger Data Attributes:**
|
||||
|
||||
| Attribute | Type | Description |
|
||||
| :-------------- | :--- | :------------------------------------------- |
|
||||
| data-panel-open | - | Present when the accordion panel is open. |
|
||||
| data-disabled | - | Present when the accordion item is disabled. |
|
||||
| Attribute | Type | Description |
|
||||
| :-------------- | :------- | :------------------------------------------- |
|
||||
| data-panel-open | - | Present when the accordion panel is open. |
|
||||
| data-disabled | - | Present when the accordion item is disabled. |
|
||||
| data-index | \`number\` | Indicates the index of the accordion item. |
|
||||
|
||||
### Trigger.Props
|
||||
|
||||
|
||||
@@ -109,10 +109,11 @@ Renders a `<button>` element.
|
||||
|
||||
**Trigger Data Attributes:**
|
||||
|
||||
| Attribute | Type | Description |
|
||||
| :-------------- | :--- | :------------------------------------------- |
|
||||
| data-panel-open | - | Present when the accordion panel is open. |
|
||||
| data-disabled | - | Present when the accordion item is disabled. |
|
||||
| Attribute | Type | Description |
|
||||
| :-------------- | :------- | :------------------------------------------- |
|
||||
| data-panel-open | - | Present when the accordion panel is open. |
|
||||
| data-disabled | - | Present when the accordion item is disabled. |
|
||||
| data-index | `number` | Indicates the index of the accordion item. |
|
||||
|
||||
### Trigger.Props
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ A set of collapsible panels with headings.
|
||||
- Data Attributes: data-disabled, data-orientation
|
||||
- Accordion - Trigger
|
||||
- Props: className, nativeButton, render, style
|
||||
- Data Attributes: data-disabled, data-panel-open
|
||||
- Data Attributes: data-disabled, data-index, data-panel-open
|
||||
- Accordion - Item
|
||||
- Props: className, disabled, onOpenChange, render, style, value
|
||||
- Data Attributes: data-disabled, data-index, data-open
|
||||
|
||||
@@ -114,9 +114,8 @@
|
||||
}
|
||||
|
||||
.QuickNavLink {
|
||||
display: flex;
|
||||
display: inline-flex;
|
||||
padding: var(--quick-nav-item-padding-y) 0.5rem;
|
||||
margin-inline: 0 -0.5rem;
|
||||
border-radius: var(--radius-6);
|
||||
|
||||
&:focus-visible {
|
||||
|
||||
@@ -142,7 +142,7 @@
|
||||
user-select: none;
|
||||
|
||||
@media (hover: hover) {
|
||||
&:not([data-active]):hover {
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 2px;
|
||||
text-decoration-thickness: 1px;
|
||||
@@ -159,7 +159,6 @@
|
||||
outline-offset: -1px;
|
||||
font-weight: var(--font-weight-400);
|
||||
word-spacing: -0.005em;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
&:focus-visible {
|
||||
|
||||
@@ -57,7 +57,8 @@ export function Item(props: ItemProps) {
|
||||
const { children, className, href, external, icon, ...other } = props;
|
||||
const ref = React.useRef<HTMLLIElement>(null);
|
||||
const pathname = usePathname();
|
||||
const active = pathname === href;
|
||||
const exactActive = pathname === href;
|
||||
const active = exactActive || pathname.startsWith(`${href}/`);
|
||||
const rem = React.useRef(16);
|
||||
|
||||
React.useEffect(() => {
|
||||
@@ -90,17 +91,18 @@ export function Item(props: ItemProps) {
|
||||
}, [active]);
|
||||
|
||||
const LinkComponent = external ? 'a' : NextLink;
|
||||
const ariaCurrent = exactActive ? 'page' : 'location';
|
||||
|
||||
return (
|
||||
<li ref={ref} {...other} className={clsx('SideNavItem', className)}>
|
||||
<LinkComponent
|
||||
className="SideNavLink"
|
||||
href={href}
|
||||
scroll={external ? undefined : !active}
|
||||
{...(active
|
||||
scroll={external ? undefined : !exactActive}
|
||||
data-active={active || undefined}
|
||||
aria-current={active ? ariaCurrent : undefined}
|
||||
{...(exactActive
|
||||
? {
|
||||
'aria-current': true,
|
||||
'data-active': true,
|
||||
onClick: () => {
|
||||
// Scroll to top smoothly when clicking on the currently active item
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
|
||||
+25
-25
@@ -3,7 +3,7 @@
|
||||
"version": "1.8.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"preinstall": "npx only-allow pnpm",
|
||||
"preinstall": "npx only-allow@1.2.2 pnpm",
|
||||
"deduplicate": "pnpm dedupe",
|
||||
"build": "lerna run --no-private build",
|
||||
"release:version": "lerna version --no-changelog --no-push --no-git-tag-version --no-private",
|
||||
@@ -69,56 +69,56 @@
|
||||
"@arethetypeswrong/cli": "0.18.5",
|
||||
"@babel/plugin-transform-react-constant-elements": "7.29.7",
|
||||
"@base-ui/monorepo-tests": "workspace:*",
|
||||
"@guidepup/guidepup": "0.33.1",
|
||||
"@guidepup/guidepup": "0.34.0",
|
||||
"@guidepup/playwright": "0.19.1",
|
||||
"@guidepup/setup": "0.24.6",
|
||||
"@microsoft/api-extractor": "7.58.12",
|
||||
"@guidepup/setup": "0.25.2",
|
||||
"@microsoft/api-extractor": "7.59.0",
|
||||
"@mui/internal-code-infra": "0.0.4-canary.111",
|
||||
"@mui/internal-netlify-cache": "0.0.3-canary.5",
|
||||
"@mui/internal-test-utils": "2.0.18-canary.25",
|
||||
"@next/eslint-plugin-next": "16.3.1",
|
||||
"@next/eslint-plugin-next": "16.3.4",
|
||||
"@playwright/test": "1.62.1",
|
||||
"@tailwindcss/postcss": "4.2.4",
|
||||
"@testing-library/jest-dom": "6.9.1",
|
||||
"@tailwindcss/postcss": "4.3.3",
|
||||
"@testing-library/jest-dom": "7.0.1",
|
||||
"@types/node": "22.20.1",
|
||||
"@types/react": "19.2.18",
|
||||
"@typescript/native": "npm:typescript@7.0.2",
|
||||
"@vitejs/plugin-react": "6.0.5",
|
||||
"@vitest/browser-playwright": "4.1.10",
|
||||
"@vitest/coverage-istanbul": "4.1.10",
|
||||
"@vitest/ui": "4.1.10",
|
||||
"concurrently": "10.0.4",
|
||||
"@vitejs/plugin-react": "6.1.1",
|
||||
"@vitest/browser-playwright": "4.1.11",
|
||||
"@vitest/coverage-istanbul": "4.1.11",
|
||||
"@vitest/ui": "4.1.11",
|
||||
"concurrently": "10.0.5",
|
||||
"cross-env": "10.1.0",
|
||||
"docs": "workspace:^",
|
||||
"eslint": "10.8.1",
|
||||
"globby": "16.2.3",
|
||||
"eslint": "10.10.0",
|
||||
"globby": "16.2.4",
|
||||
"jsdom": "27.4.0",
|
||||
"lerna": "9.0.7",
|
||||
"lerna": "10.0.1",
|
||||
"pkg-pr-new": "0.0.88",
|
||||
"postcss-value-parser": "4.2.0",
|
||||
"prettier": "3.9.6",
|
||||
"pretty-quick": "4.2.2",
|
||||
"publint": "0.3.20",
|
||||
"publint": "0.3.24",
|
||||
"react": "19.2.8",
|
||||
"react-dom": "19.2.8",
|
||||
"remark-mdx": "3.1.1",
|
||||
"rimraf": "6.1.3",
|
||||
"serve": "14.2.6",
|
||||
"stylelint": "17.11.0",
|
||||
"stylelint": "17.15.0",
|
||||
"stylelint-config-tailwindcss": "1.0.1",
|
||||
"tailwindcss": "4.2.4",
|
||||
"terser": "5.49.2",
|
||||
"tsx": "4.23.12",
|
||||
"tailwindcss": "4.3.3",
|
||||
"terser": "5.51.2",
|
||||
"tsx": "4.23.13",
|
||||
"typescript": "npm:@typescript/typescript6@6.0.2",
|
||||
"vite": "8.2.1",
|
||||
"vitest": "4.1.10"
|
||||
"vite": "8.2.2",
|
||||
"vitest": "4.1.11"
|
||||
},
|
||||
"config": {
|
||||
"valeVersion": "3.14.1"
|
||||
"valeVersion": "3.21.0"
|
||||
},
|
||||
"packageManager": "pnpm@11.21.0",
|
||||
"packageManager": "pnpm@12.4.1",
|
||||
"engines": {
|
||||
"pnpm": "11.21.0",
|
||||
"pnpm": "12.4.1",
|
||||
"node": ">=22.23.2"
|
||||
}
|
||||
}
|
||||
@@ -138,18 +138,18 @@
|
||||
"@date-fns/tz": "1.5.0",
|
||||
"@testing-library/react": "16.3.2",
|
||||
"@testing-library/user-event": "14.6.3",
|
||||
"@types/luxon": "3.7.4",
|
||||
"@types/luxon": "3.7.5",
|
||||
"@types/react": "19.2.18",
|
||||
"@types/react-dom": "19.2.4",
|
||||
"@types/react-dom": "19.2.7",
|
||||
"@types/use-sync-external-store": "1.5.0",
|
||||
"clsx": "2.1.1",
|
||||
"date-fns": "4.4.0",
|
||||
"luxon": "3.7.2",
|
||||
"react": "19.2.8",
|
||||
"react-dom": "19.2.8",
|
||||
"react-router": "7.18.2",
|
||||
"react-router": "8.3.1",
|
||||
"typescript": "npm:@typescript/typescript6@6.0.2",
|
||||
"vitest-browser-react": "2.2.0"
|
||||
"vitest-browser-react": "2.3.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@date-fns/tz": "^1.2.0",
|
||||
|
||||
@@ -35,4 +35,65 @@ describe('<Accordion.Trigger />', () => {
|
||||
const trigger = screen.getByRole('button', { name: 'Trigger' });
|
||||
expect(trigger).toHaveAttribute('tabindex', '0');
|
||||
});
|
||||
|
||||
it('does not render the root value as data-value', async () => {
|
||||
await render(
|
||||
<Accordion.Root value={['a', 'b']} multiple>
|
||||
<Accordion.Item value="a">
|
||||
<Accordion.Header>
|
||||
<Accordion.Trigger>header a</Accordion.Trigger>
|
||||
</Accordion.Header>
|
||||
<Accordion.Panel>panel a</Accordion.Panel>
|
||||
</Accordion.Item>
|
||||
<Accordion.Item value="b">
|
||||
<Accordion.Header>
|
||||
<Accordion.Trigger>header b</Accordion.Trigger>
|
||||
</Accordion.Header>
|
||||
<Accordion.Panel>panel b</Accordion.Panel>
|
||||
</Accordion.Item>
|
||||
</Accordion.Root>,
|
||||
);
|
||||
|
||||
const triggers = screen.getAllByRole('button');
|
||||
expect(triggers[0]).not.toHaveAttribute('data-value');
|
||||
expect(triggers[1]).not.toHaveAttribute('data-value');
|
||||
});
|
||||
|
||||
it('renders data-index on every trigger including the first', async () => {
|
||||
await render(
|
||||
<Accordion.Root>
|
||||
<Accordion.Item>
|
||||
<Accordion.Header>
|
||||
<Accordion.Trigger>first</Accordion.Trigger>
|
||||
</Accordion.Header>
|
||||
</Accordion.Item>
|
||||
<Accordion.Item>
|
||||
<Accordion.Header>
|
||||
<Accordion.Trigger>second</Accordion.Trigger>
|
||||
</Accordion.Header>
|
||||
</Accordion.Item>
|
||||
</Accordion.Root>,
|
||||
);
|
||||
|
||||
const triggers = screen.getAllByRole('button');
|
||||
expect(triggers[0]).toHaveAttribute('data-index', '0');
|
||||
expect(triggers[1]).toHaveAttribute('data-index', '1');
|
||||
});
|
||||
|
||||
it('keeps data-panel-open instead of data-open', async () => {
|
||||
await render(
|
||||
<Accordion.Root value={['a']}>
|
||||
<Accordion.Item value="a">
|
||||
<Accordion.Header>
|
||||
<Accordion.Trigger>header a</Accordion.Trigger>
|
||||
</Accordion.Header>
|
||||
<Accordion.Panel>panel a</Accordion.Panel>
|
||||
</Accordion.Item>
|
||||
</Accordion.Root>,
|
||||
);
|
||||
|
||||
const trigger = screen.getByRole('button', { name: 'header a' });
|
||||
expect(trigger).toHaveAttribute('data-panel-open');
|
||||
expect(trigger).not.toHaveAttribute('data-open');
|
||||
});
|
||||
});
|
||||
@@ -5,10 +5,17 @@ import { triggerOpenStateMapping } from '../../utils/collapsibleOpenStateMapping
|
||||
import { BaseUIComponentProps, NativeButtonProps } from '../../internals/types';
|
||||
import { useButton } from '../../internals/use-button';
|
||||
import { useCollapsibleRootContext } from '../../collapsible/root/CollapsibleRootContext';
|
||||
import type { StateAttributesMapping } from '../../internals/getStateAttributesProps';
|
||||
import type { AccordionItemState } from '../item/AccordionItem';
|
||||
import { useAccordionItemContext } from '../item/AccordionItemContext';
|
||||
import { accordionStateAttributesMapping } from '../item/stateAttributesMapping';
|
||||
import { useRenderElement } from '../../internals/useRenderElement';
|
||||
|
||||
const stateAttributesMapping: StateAttributesMapping<AccordionItemState> = {
|
||||
...accordionStateAttributesMapping,
|
||||
...triggerOpenStateMapping,
|
||||
};
|
||||
|
||||
/**
|
||||
* A button that opens and closes the corresponding panel.
|
||||
* Renders a `<button>` element.
|
||||
@@ -62,7 +69,7 @@ export const AccordionTrigger = React.forwardRef(function AccordionTrigger(
|
||||
state,
|
||||
ref: [forwardedRef, buttonRef],
|
||||
props: [props, elementProps, getButtonProps],
|
||||
stateAttributesMapping: triggerOpenStateMapping,
|
||||
stateAttributesMapping,
|
||||
});
|
||||
|
||||
return element;
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* Indicates the index of the accordion item.
|
||||
* @type {number}
|
||||
*/
|
||||
export const index = 'data-index';
|
||||
/**
|
||||
* Present when the accordion panel is open.
|
||||
*/
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
useClick,
|
||||
} from '../../floating-ui-react';
|
||||
import { gridNavigation } from '../../floating-ui-react/hooks/gridNavigation';
|
||||
import { contains, getTarget } from '../../floating-ui-react/utils';
|
||||
import { closest, contains, getTarget } from '../../floating-ui-react/utils';
|
||||
import {
|
||||
createChangeEventDetails,
|
||||
createGenericEventDetails,
|
||||
@@ -861,7 +861,7 @@ export function AriaCombobox<Value = any, Mode extends SelectionMode = 'none', I
|
||||
const eventDetails = createChangeEventDetails(REASONS.itemPress, overrideEvent);
|
||||
|
||||
// Let the link handle the click.
|
||||
const href = targetEl?.closest('a')?.getAttribute('href');
|
||||
const href = closest(targetEl, 'a')?.getAttribute('href');
|
||||
if (href) {
|
||||
if (href.startsWith('#')) {
|
||||
setOpen(false, eventDetails);
|
||||
@@ -975,7 +975,7 @@ export function AriaCombobox<Value = any, Mode extends SelectionMode = 'none', I
|
||||
// `role=dialog` part must be the animated element.
|
||||
const resolvedPopupRef: React.RefObject<HTMLElement | null> = React.useMemo(() => {
|
||||
if (inline && positionerElement) {
|
||||
return { current: positionerElement.closest('[role="dialog"]') };
|
||||
return { current: closest(positionerElement, '[role="dialog"]') };
|
||||
}
|
||||
return popupRef;
|
||||
}, [inline, positionerElement]);
|
||||
|
||||
@@ -292,6 +292,28 @@ function App3() {
|
||||
);
|
||||
}
|
||||
|
||||
function ReadonlyMultipleValues() {
|
||||
const [value, setValue] = React.useState<string[]>([]);
|
||||
const readonlyValue: readonly string[] = value;
|
||||
const tupleValue = ['javascript', 'typescript'] as const;
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Combobox.Root multiple value={readonlyValue} onValueChange={setValue} />
|
||||
<Combobox.Root multiple defaultValue={readonlyValue} onValueChange={setValue} />
|
||||
<Combobox.Root
|
||||
multiple
|
||||
value={tupleValue}
|
||||
onValueChange={(newValue) => {
|
||||
expectType<('javascript' | 'typescript')[], typeof newValue>(newValue);
|
||||
newValue.pop();
|
||||
}}
|
||||
/>
|
||||
<Combobox.Root multiple defaultValue={tupleValue} onValueChange={setValue} />
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
mergeProps<typeof Combobox.Root<any>>(
|
||||
{
|
||||
value: '',
|
||||
|
||||
@@ -36,7 +36,11 @@ type ModeFromMultiple<Multiple extends boolean | undefined> = Multiple extends t
|
||||
? 'multiple'
|
||||
: 'single';
|
||||
|
||||
type ComboboxValueType<Value, Multiple extends boolean | undefined> = Multiple extends true
|
||||
type ComboboxInputValue<Value, Multiple extends boolean | undefined> = Multiple extends true
|
||||
? readonly Value[]
|
||||
: Value;
|
||||
|
||||
type ComboboxOutputValue<Value, Multiple extends boolean | undefined> = Multiple extends true
|
||||
? Value[]
|
||||
: Value;
|
||||
|
||||
@@ -112,7 +116,7 @@ export type ComboboxRootProps<
|
||||
*
|
||||
* To render a controlled combobox, use the `value` prop instead.
|
||||
*/
|
||||
defaultValue?: ComboboxValueType<Value, Multiple> | null | undefined;
|
||||
defaultValue?: ComboboxInputValue<Value, Multiple> | null | undefined;
|
||||
/**
|
||||
* A ref to imperative actions.
|
||||
* - `unmount`: Manually unmounts the combobox.
|
||||
@@ -146,13 +150,13 @@ export type ComboboxRootProps<
|
||||
/**
|
||||
* The selected value of the combobox. Use when controlled.
|
||||
*/
|
||||
value?: ComboboxValueType<Value, Multiple> | null | undefined;
|
||||
value?: ComboboxInputValue<Value, Multiple> | null | undefined;
|
||||
/**
|
||||
* Event handler called when the selected value of the combobox changes.
|
||||
*/
|
||||
onValueChange?:
|
||||
| ((
|
||||
value: ComboboxValueType<Value, Multiple> | (Multiple extends true ? never : null),
|
||||
value: ComboboxOutputValue<Value, Multiple> | (Multiple extends true ? never : null),
|
||||
eventDetails: ComboboxRoot.ChangeEventDetails,
|
||||
) => void)
|
||||
| undefined;
|
||||
|
||||
@@ -636,7 +636,9 @@ describe('<Dialog.Popup />', () => {
|
||||
|
||||
// Close via keyboard: should move focus to final-input
|
||||
await user.click(trigger);
|
||||
await waitSingleFrame();
|
||||
await act(async () => {
|
||||
await waitSingleFrame();
|
||||
});
|
||||
await user.keyboard('{Escape}');
|
||||
await waitFor(() => {
|
||||
expect(screen.getByTestId('final-input')).toHaveFocus();
|
||||
|
||||
@@ -2164,5 +2164,143 @@ describe('<Dialog.Root />', () => {
|
||||
expect(screen.queryByRole('dialog')).toBe(null);
|
||||
});
|
||||
});
|
||||
|
||||
it('does not associate the only rendered trigger when opened with a payload', async () => {
|
||||
const dialog = Dialog.createHandle<string>();
|
||||
const { user } = await render(
|
||||
<div>
|
||||
<Dialog.Trigger handle={dialog} id="trigger" payload="from trigger">
|
||||
Trigger
|
||||
</Dialog.Trigger>
|
||||
<Dialog.Root handle={dialog}>
|
||||
{({ payload }: { payload: string | undefined }) => (
|
||||
<Dialog.Portal>
|
||||
<Dialog.Popup data-testid="content">{payload}</Dialog.Popup>
|
||||
</Dialog.Portal>
|
||||
)}
|
||||
</Dialog.Root>
|
||||
</div>,
|
||||
);
|
||||
|
||||
const trigger = screen.getByRole('button', { name: 'Trigger' });
|
||||
|
||||
await act(() => dialog.openWithPayload('from openWithPayload'));
|
||||
await waitFor(() => {
|
||||
expect(screen.queryByRole('dialog')).not.toBe(null);
|
||||
});
|
||||
|
||||
expect(screen.getByTestId('content').textContent).toBe('from openWithPayload');
|
||||
expect(trigger).toHaveAttribute('aria-expanded', 'false');
|
||||
expect(trigger).not.toHaveAttribute('aria-controls');
|
||||
expect(trigger).not.toHaveAttribute('data-popup-open');
|
||||
|
||||
await act(() => dialog.close());
|
||||
await waitFor(() => {
|
||||
expect(screen.queryByRole('dialog')).toBe(null);
|
||||
});
|
||||
|
||||
// Opening through the trigger afterwards still associates it and forwards its payload.
|
||||
await user.click(trigger);
|
||||
await waitFor(() => {
|
||||
expect(screen.queryByRole('dialog')).not.toBe(null);
|
||||
});
|
||||
expect(screen.getByTestId('content').textContent).toBe('from trigger');
|
||||
expect(trigger).toHaveAttribute('aria-expanded', 'true');
|
||||
expect(trigger.getAttribute('aria-controls')).toBe(
|
||||
screen.getByRole('dialog').getAttribute('id'),
|
||||
);
|
||||
});
|
||||
|
||||
it('does not let a trigger that mounts while open replace the programmatic payload', async () => {
|
||||
const dialog = Dialog.createHandle<string>();
|
||||
|
||||
function App({ showTrigger }: { showTrigger: boolean }) {
|
||||
return (
|
||||
<div>
|
||||
{showTrigger && (
|
||||
<Dialog.Trigger handle={dialog} id="trigger" payload="from trigger">
|
||||
Trigger
|
||||
</Dialog.Trigger>
|
||||
)}
|
||||
<Dialog.Root handle={dialog}>
|
||||
{({ payload }: { payload: string | undefined }) => (
|
||||
<Dialog.Portal>
|
||||
<Dialog.Popup data-testid="content">{payload}</Dialog.Popup>
|
||||
</Dialog.Portal>
|
||||
)}
|
||||
</Dialog.Root>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const { setProps } = await render(<App showTrigger={false} />);
|
||||
|
||||
await act(() => dialog.openWithPayload('from openWithPayload'));
|
||||
await waitFor(() => {
|
||||
expect(screen.queryByRole('dialog')).not.toBe(null);
|
||||
});
|
||||
expect(screen.getByTestId('content').textContent).toBe('from openWithPayload');
|
||||
|
||||
await setProps({ showTrigger: true });
|
||||
|
||||
expect(screen.getByTestId('content').textContent).toBe('from openWithPayload');
|
||||
// The modal dialog hides the rest of the page from the accessibility tree.
|
||||
const trigger = screen.getByRole('button', { name: 'Trigger', hidden: true });
|
||||
expect(trigger).toHaveAttribute('aria-expanded', 'false');
|
||||
expect(trigger).not.toHaveAttribute('aria-controls');
|
||||
});
|
||||
|
||||
it('keeps the programmatic payload when a controlled dialog declines a close request', async () => {
|
||||
const dialog = Dialog.createHandle<string>();
|
||||
|
||||
function App({ showTrigger }: { showTrigger: boolean }) {
|
||||
const [open, setOpen] = React.useState(false);
|
||||
|
||||
return (
|
||||
<div>
|
||||
{showTrigger && (
|
||||
<Dialog.Trigger handle={dialog} id="trigger" payload="from trigger">
|
||||
Trigger
|
||||
</Dialog.Trigger>
|
||||
)}
|
||||
<Dialog.Root
|
||||
handle={dialog}
|
||||
open={open}
|
||||
onOpenChange={(nextOpen) => {
|
||||
// Accept opens, but keep the dialog open on close requests.
|
||||
if (nextOpen) {
|
||||
setOpen(true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{({ payload }: { payload: string | undefined }) => (
|
||||
<Dialog.Portal>
|
||||
<Dialog.Popup data-testid="content">{payload}</Dialog.Popup>
|
||||
</Dialog.Portal>
|
||||
)}
|
||||
</Dialog.Root>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const { setProps } = await render(<App showTrigger={false} />);
|
||||
|
||||
await act(() => dialog.openWithPayload('from openWithPayload'));
|
||||
await waitFor(() => {
|
||||
expect(screen.queryByRole('dialog')).not.toBe(null);
|
||||
});
|
||||
|
||||
// The close request is declined, so the dialog stays open without a trigger.
|
||||
await act(() => dialog.close());
|
||||
expect(screen.queryByRole('dialog')).not.toBe(null);
|
||||
expect(dialog.isOpen).toBe(true);
|
||||
|
||||
await setProps({ showTrigger: true });
|
||||
|
||||
expect(screen.getByTestId('content').textContent).toBe('from openWithPayload');
|
||||
const trigger = screen.getByRole('button', { name: 'Trigger', hidden: true });
|
||||
expect(trigger).toHaveAttribute('aria-expanded', 'false');
|
||||
expect(trigger).not.toHaveAttribute('aria-controls');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -32,7 +32,7 @@ import * as DrawerBackdropCssVars from '../backdrop/DrawerBackdropCssVars';
|
||||
import { DRAWER_CONTENT_ATTRIBUTE } from '../content/drawerContentAttribute';
|
||||
import { REASONS } from '../../internals/reasons';
|
||||
import { createChangeEventDetails } from '../../internals/createBaseUIEventDetails';
|
||||
import { activeElement, contains, getTarget } from '../../floating-ui-react/utils';
|
||||
import { activeElement, closest, contains, getTarget } from '../../floating-ui-react/utils';
|
||||
import { DrawerViewportContext } from './DrawerViewportContext';
|
||||
import { TransitionStatusDataAttributes } from '../../internals/stateAttributesMapping';
|
||||
import { findScrollableTouchTarget, type ScrollAxis } from '../../utils/scrollable';
|
||||
@@ -1060,11 +1060,11 @@ function setBackdropSwipingAttribute(backdropElement: HTMLElement | null, swipin
|
||||
}
|
||||
|
||||
function isSwipeIgnoredTarget(target: Element | null): boolean {
|
||||
return Boolean(target?.closest(BASE_UI_SWIPE_IGNORE_SELECTOR));
|
||||
return Boolean(closest(target, BASE_UI_SWIPE_IGNORE_SELECTOR));
|
||||
}
|
||||
|
||||
function isDrawerContentTarget(target: Element | null): boolean {
|
||||
return Boolean(target?.closest(DRAWER_CONTENT_SELECTOR));
|
||||
return Boolean(closest(target, DRAWER_CONTENT_SELECTOR));
|
||||
}
|
||||
|
||||
function getBaseSwipeSize(element: HTMLElement, direction: SwipeDirection): number {
|
||||
|
||||
+3
-2
@@ -10,6 +10,7 @@ import { useTimeout } from '@base-ui/utils/useTimeout';
|
||||
import { useDialogRootContext } from '../../dialog/root/DialogRootContext';
|
||||
import {
|
||||
activeElement,
|
||||
closest,
|
||||
contains,
|
||||
getTarget,
|
||||
isInteractiveElement,
|
||||
@@ -693,7 +694,7 @@ function resolveKeyboardInputTarget(target: EventTarget | null): HTMLElement | n
|
||||
return target.isContentEditable ? getContentEditableHost(target) : target;
|
||||
}
|
||||
|
||||
const label = target.closest('label') as HTMLLabelElement | null;
|
||||
const label = closest(target, 'label');
|
||||
const control = label?.control ?? null;
|
||||
|
||||
return isHTMLElement(control) && isKeyboardInputElement(control) ? control : null;
|
||||
@@ -747,7 +748,7 @@ function resolveKeyboardTouchTargetFromPoint(
|
||||
// `closest('label')` covers labels of non-keyboard controls (e.g. checkboxes).
|
||||
// Returning the blocked sentinel (rather than `null`) stops the caller from falling
|
||||
// back to the touchstart target, which would re-steal the very tap rejected here.
|
||||
if (isInteractiveElement(exactTarget) || exactTarget?.closest('label') != null) {
|
||||
if (isInteractiveElement(exactTarget) || closest(exactTarget, 'label') != null) {
|
||||
return KEYBOARD_TAP_BLOCKED;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import { ownerDocument, ownerWindow } from '@base-ui/utils/owner';
|
||||
import { FocusGuard } from '../../utils/FocusGuard';
|
||||
import {
|
||||
activeElement,
|
||||
closest,
|
||||
contains,
|
||||
getTarget,
|
||||
isTypeableCombobox,
|
||||
@@ -371,7 +372,7 @@ export function FloatingFocusManager(props: FloatingFocusManagerProps): React.JS
|
||||
lastInteractionTypeRef.current =
|
||||
(event.pointerType as React.PointerEvent['pointerType']) || 'keyboard';
|
||||
|
||||
if (target?.closest(`[${CLICK_TRIGGER_IDENTIFIER}]`)) {
|
||||
if (closest(target, `[${CLICK_TRIGGER_IDENTIFIER}]`)) {
|
||||
isPointerDownRef.current = true;
|
||||
// Reset on the next tick so a single click on a click-trigger doesn't
|
||||
// permanently suppress focus-out closing for the lifetime of the instance.
|
||||
|
||||
@@ -11,7 +11,7 @@ import { createChangeEventDetails } from '../../internals/createBaseUIEventDetai
|
||||
import { REASONS } from '../../internals/reasons';
|
||||
import { useFloatingParentNodeId, useFloatingTree } from '../components/FloatingTree';
|
||||
import type { FloatingContext, FloatingRootContext } from '../types';
|
||||
import { contains, getTarget } from '../utils/element';
|
||||
import { closest, contains, getTarget } from '../utils/element';
|
||||
import { getNodeChildren } from '../utils/nodes';
|
||||
import {
|
||||
applySafePolygonPointerEventsMutation,
|
||||
@@ -128,7 +128,7 @@ export function useHoverFloatingInteraction(
|
||||
instance.handleCloseOptions?.getScope?.() ??
|
||||
cachedScopeElement ??
|
||||
parentScopeElement ??
|
||||
(ref.closest('[data-rootownerid]') as HTMLElement | SVGSVGElement | null) ??
|
||||
(closest(ref, '[data-rootownerid]') as HTMLElement | SVGSVGElement | null) ??
|
||||
doc.body;
|
||||
|
||||
applySafePolygonPointerEventsMutation(instance, {
|
||||
@@ -186,7 +186,7 @@ export function useHoverFloatingInteraction(
|
||||
return;
|
||||
}
|
||||
|
||||
instance.interactedInside = target?.closest('[aria-haspopup]') != null;
|
||||
instance.interactedInside = closest(target, '[aria-haspopup]') != null;
|
||||
}
|
||||
|
||||
function onFloatingMouseEnter() {
|
||||
|
||||
@@ -4,6 +4,7 @@ import { getComputedStyle } from '@floating-ui/utils/dom';
|
||||
import type { Dimensions } from '../types';
|
||||
import { stopEvent } from './event';
|
||||
import { ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, ARROW_UP } from './constants';
|
||||
import { closest } from './element';
|
||||
|
||||
export type DisabledIndices = ReadonlyArray<number> | ((index: number) => boolean);
|
||||
|
||||
@@ -117,7 +118,7 @@ export function getGridNavigatedIndex(
|
||||
|
||||
visibleItemCount += 1;
|
||||
|
||||
const rowEl = el.closest('[role="row"]');
|
||||
const rowEl = closest(el, '[role="row"]');
|
||||
if (rowEl) {
|
||||
hasRoleRow = true;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { isElement, isHTMLElement } from '@floating-ui/utils/dom';
|
||||
import { platform } from '@base-ui/utils/platform';
|
||||
import { activeElement, contains, getTarget } from '@base-ui/utils/shadowDom';
|
||||
import { activeElement, closest, contains, getTarget } from '@base-ui/utils/shadowDom';
|
||||
import { FOCUSABLE_ATTRIBUTE, TYPEABLE_SELECTOR } from './constants';
|
||||
import { type PopupTriggerMap } from '../../utils/popups';
|
||||
import * as TooltipTriggerDataAttributes from '../../tooltip/trigger/TooltipTriggerDataAttributes';
|
||||
|
||||
export { activeElement, contains, getTarget };
|
||||
export { activeElement, closest, contains, getTarget };
|
||||
|
||||
export function isTargetInsideEnabledTrigger(
|
||||
target: EventTarget | null,
|
||||
@@ -54,7 +54,8 @@ export function isTypeableElement(element: unknown): boolean {
|
||||
|
||||
export function isInteractiveElement(element: Element | null) {
|
||||
return (
|
||||
element?.closest(
|
||||
closest(
|
||||
element,
|
||||
`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`,
|
||||
) != null
|
||||
);
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import * as React from 'react';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { act, screen } from '@mui/internal-test-utils';
|
||||
import { createRenderer } from '#test-utils';
|
||||
import { useLabel } from './useLabel';
|
||||
|
||||
describe('useLabel', () => {
|
||||
const { render } = createRenderer();
|
||||
|
||||
it('does not focus the control when a composed click originates inside a nested button', async () => {
|
||||
function Test() {
|
||||
const labelProps = useLabel({ fallbackControlId: 'control' });
|
||||
const hostRef = React.useCallback((host: HTMLSpanElement | null) => {
|
||||
if (host && !host.shadowRoot) {
|
||||
const target = document.createElement('span');
|
||||
target.dataset.testid = 'shadow-target';
|
||||
host.attachShadow({ mode: 'open' }).appendChild(target);
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<div {...labelProps}>
|
||||
Label
|
||||
<button type="button">
|
||||
Action
|
||||
<span ref={hostRef} />
|
||||
</button>
|
||||
</div>
|
||||
<input id="control" />
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
await render(<Test />);
|
||||
|
||||
const button = screen.getByRole('button');
|
||||
const target = button.querySelector('span')?.shadowRoot?.querySelector('span');
|
||||
const control = screen.getByRole('textbox');
|
||||
|
||||
expect(target).not.toBeNull();
|
||||
|
||||
await act(async () => {
|
||||
target?.dispatchEvent(new MouseEvent('click', { bubbles: true, composed: true }));
|
||||
});
|
||||
|
||||
expect(control).not.toHaveFocus();
|
||||
});
|
||||
});
|
||||
@@ -3,7 +3,7 @@ import * as React from 'react';
|
||||
import { isHTMLElement } from '@floating-ui/utils/dom';
|
||||
import { ownerDocument } from '@base-ui/utils/owner';
|
||||
import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
||||
import { getTarget } from '../../floating-ui-react/utils';
|
||||
import { closest, getTarget } from '../../floating-ui-react/utils';
|
||||
import { useRegisteredLabelId } from '../../utils/useRegisteredLabelId';
|
||||
import { useLabelableContext } from './LabelableContext';
|
||||
|
||||
@@ -45,7 +45,7 @@ export function useLabel(params: UseLabelParameters = {}): UseLabelReturnValue {
|
||||
|
||||
function handleInteraction(event: React.MouseEvent) {
|
||||
const target = getTarget(event.nativeEvent) as HTMLElement | null;
|
||||
if (target?.closest('button,input,select,textarea')) {
|
||||
if (closest(target, 'button,input,select,textarea')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,7 @@ const FORMATS: TemporalAdapterFormats = {
|
||||
// Letter formats
|
||||
month3Letters: 'MMM',
|
||||
monthFullLetter: 'MMMM',
|
||||
monthFullLetterStandalone: 'LLLL',
|
||||
weekday: 'EEEE',
|
||||
weekday3Letters: 'EEE',
|
||||
weekday1Letter: 'EEEEE',
|
||||
|
||||
@@ -29,6 +29,7 @@ const FORMATS: TemporalAdapterFormats = {
|
||||
// Letter formats
|
||||
month3Letters: 'MMM',
|
||||
monthFullLetter: 'MMMM',
|
||||
monthFullLetterStandalone: 'LLLL',
|
||||
weekday: 'cccc',
|
||||
weekday3Letters: 'ccc',
|
||||
weekday1Letter: 'ccccc',
|
||||
|
||||
@@ -61,6 +61,11 @@ export interface TemporalAdapterFormats {
|
||||
* @example "August"
|
||||
*/
|
||||
monthFullLetter: string;
|
||||
/**
|
||||
* The full month name in standalone form (nominative), for use without a day number.
|
||||
* @example "August", "czerwiec" (Polish nominative vs. "czerwca" genitive with {@link monthFullLetter})
|
||||
*/
|
||||
monthFullLetterStandalone: string;
|
||||
/**
|
||||
* The week day name.
|
||||
* @example "Wednesday"
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
||||
import { createRenderer } from '#test-utils';
|
||||
import { useAnimationsFinished } from './useAnimationsFinished';
|
||||
|
||||
function createAnimation() {
|
||||
function createAnimation(iterations = 1, duration = 1) {
|
||||
let resolveFinished!: () => void;
|
||||
let rejectFinished!: () => void;
|
||||
|
||||
@@ -18,6 +18,7 @@ function createAnimation() {
|
||||
return {
|
||||
animation: {
|
||||
finished,
|
||||
effect: { getTiming: () => ({ duration, iterations }) },
|
||||
pending: false,
|
||||
playState: 'running',
|
||||
} as unknown as Animation,
|
||||
@@ -53,14 +54,65 @@ function Test({ getAnimations, onFinished, signal, batch }: TestProps) {
|
||||
describe('useAnimationsFinished', () => {
|
||||
const { render } = createRenderer();
|
||||
|
||||
it.each(['finish', 'cancel'] as const)(
|
||||
'ignores infinite animations when a finite animation completes via %s',
|
||||
async (completion) => {
|
||||
const animationsDisabled = globalThis.BASE_UI_ANIMATIONS_DISABLED;
|
||||
globalThis.BASE_UI_ANIMATIONS_DISABLED = false;
|
||||
|
||||
const finite = createAnimation();
|
||||
const infinite = createAnimation(Infinity);
|
||||
const onFinished = vi.fn();
|
||||
let animations = [finite.animation, infinite.animation];
|
||||
const getAnimations = vi.fn(() => animations);
|
||||
|
||||
try {
|
||||
await render(<Test getAnimations={getAnimations} onFinished={onFinished} />);
|
||||
await waitFor(() => expect(getAnimations).toHaveBeenCalled());
|
||||
expect(onFinished).not.toHaveBeenCalled();
|
||||
|
||||
animations = [infinite.animation];
|
||||
await act(async () => {
|
||||
finite[completion]();
|
||||
await flushMicrotasks();
|
||||
});
|
||||
|
||||
expect(onFinished).toHaveBeenCalledTimes(1);
|
||||
} finally {
|
||||
globalThis.BASE_UI_ANIMATIONS_DISABLED = animationsDisabled;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
it.each([
|
||||
['iteration count', Infinity, 1],
|
||||
['duration', 1, Infinity],
|
||||
] as const)(
|
||||
'finishes when the element only has an animation with an infinite %s',
|
||||
async (_timing, iterations, duration) => {
|
||||
const animationsDisabled = globalThis.BASE_UI_ANIMATIONS_DISABLED;
|
||||
globalThis.BASE_UI_ANIMATIONS_DISABLED = false;
|
||||
const infinite = createAnimation(iterations, duration);
|
||||
const onFinished = vi.fn();
|
||||
|
||||
try {
|
||||
await render(<Test getAnimations={() => [infinite.animation]} onFinished={onFinished} />);
|
||||
await waitFor(() => expect(onFinished).toHaveBeenCalledTimes(1));
|
||||
} finally {
|
||||
globalThis.BASE_UI_ANIMATIONS_DISABLED = animationsDisabled;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
it('waits for a replacement animation after an animation is canceled', async () => {
|
||||
const animationsDisabled = globalThis.BASE_UI_ANIMATIONS_DISABLED;
|
||||
globalThis.BASE_UI_ANIMATIONS_DISABLED = false;
|
||||
|
||||
const initialAnimation = createAnimation();
|
||||
const replacementAnimation = createAnimation();
|
||||
const infiniteAnimation = createAnimation(Infinity);
|
||||
const onFinished = vi.fn();
|
||||
let animations: Animation[] = [initialAnimation.animation];
|
||||
let animations: Animation[] = [initialAnimation.animation, infiniteAnimation.animation];
|
||||
let getAnimationsCallCount = 0;
|
||||
|
||||
try {
|
||||
@@ -78,7 +130,7 @@ describe('useAnimationsFinished', () => {
|
||||
expect(getAnimationsCallCount).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
animations = [replacementAnimation.animation];
|
||||
animations = [replacementAnimation.animation, infiniteAnimation.animation];
|
||||
|
||||
await act(async () => {
|
||||
initialAnimation.cancel();
|
||||
|
||||
@@ -3,7 +3,9 @@ import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import { useAnimationFrame } from '@base-ui/utils/useAnimationFrame';
|
||||
import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
||||
import { NOOP } from '@base-ui/utils/empty';
|
||||
import { resolveRef } from '../utils/resolveRef';
|
||||
import { getFiniteAnimations } from '../utils/getFiniteAnimations';
|
||||
import * as TransitionStatusDataAttributes from './TransitionStatusDataAttributes';
|
||||
|
||||
let pendingCallbacks: Array<() => void> | null = null;
|
||||
@@ -97,7 +99,10 @@ export function useAnimationsFinished(
|
||||
}
|
||||
|
||||
function exec() {
|
||||
Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(
|
||||
// Discard fulfilled Animation values so unfinished animations cannot retain their targets.
|
||||
Promise.all(
|
||||
getFiniteAnimations(resolvedElement).map((animation) => animation.finished.then(NOOP)),
|
||||
).then(
|
||||
() => {
|
||||
if (!signal?.aborted) {
|
||||
done();
|
||||
@@ -108,7 +113,7 @@ export function useAnimationsFinished(
|
||||
return;
|
||||
}
|
||||
|
||||
const currentAnimations = resolvedElement.getAnimations();
|
||||
const currentAnimations = getFiniteAnimations(resolvedElement);
|
||||
|
||||
if (
|
||||
currentAnimations.some(
|
||||
|
||||
@@ -0,0 +1,278 @@
|
||||
import * as React from 'react';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { act, screen, waitFor } from '@mui/internal-test-utils';
|
||||
import { Menu } from '@base-ui/react/menu';
|
||||
import { useIsoLayoutEffect } from '@base-ui/utils/useIsoLayoutEffect';
|
||||
import { DirectionProvider } from '@base-ui/react/direction-provider';
|
||||
import { createRenderer, resetBrowserPointer } from '#test-utils';
|
||||
import { useMenuRootContext } from './MenuRootContext';
|
||||
|
||||
function Popup({ children, ...props }: Menu.Portal.Props) {
|
||||
return (
|
||||
<Menu.Portal {...props}>
|
||||
<Menu.Positioner anchor={document.body}>
|
||||
<Menu.Popup>{children}</Menu.Popup>
|
||||
</Menu.Positioner>
|
||||
</Menu.Portal>
|
||||
);
|
||||
}
|
||||
|
||||
function Submenu({
|
||||
label,
|
||||
children,
|
||||
openOnHover = false,
|
||||
...props
|
||||
}: Menu.SubmenuRoot.Props & { label: string; openOnHover?: boolean }) {
|
||||
return (
|
||||
<Menu.SubmenuRoot {...props}>
|
||||
<Menu.SubmenuTrigger openOnHover={openOnHover} delay={0}>
|
||||
{label}
|
||||
</Menu.SubmenuTrigger>
|
||||
<Menu.Portal>
|
||||
<Menu.Positioner>
|
||||
<Menu.Popup>{children}</Menu.Popup>
|
||||
</Menu.Positioner>
|
||||
</Menu.Portal>
|
||||
</Menu.SubmenuRoot>
|
||||
);
|
||||
}
|
||||
|
||||
describe('<Menu.Root /> without a trigger', () => {
|
||||
const { render } = createRenderer();
|
||||
|
||||
beforeEach(resetBrowserPointer);
|
||||
beforeEach(() => {
|
||||
globalThis.BASE_UI_ANIMATIONS_DISABLED = true;
|
||||
});
|
||||
|
||||
async function focusItem(name: string) {
|
||||
const item = await screen.findByRole('menuitem', { name });
|
||||
await act(async () => item.focus());
|
||||
return item;
|
||||
}
|
||||
|
||||
describe.each(['ltr', 'rtl'] as const)('%s', (direction) => {
|
||||
it.each([false, true])(
|
||||
'keeps nested Escape and focus local, keepMounted=%s',
|
||||
async (keepMounted) => {
|
||||
const changed = vi.fn();
|
||||
const { user } = await render(
|
||||
<DirectionProvider direction={direction}>
|
||||
<Menu.Root defaultOpen modal={false} onOpenChange={changed}>
|
||||
<Popup keepMounted={keepMounted}>
|
||||
<Submenu label="More">
|
||||
<Menu.Item>Leaf</Menu.Item>
|
||||
</Submenu>
|
||||
</Popup>
|
||||
</Menu.Root>
|
||||
</DirectionProvider>,
|
||||
);
|
||||
const more = await focusItem('More');
|
||||
const root = screen.getByRole('menu');
|
||||
const openKey = direction === 'rtl' ? '{ArrowLeft}' : '{ArrowRight}';
|
||||
await user.keyboard(openKey);
|
||||
await waitFor(() => expect(screen.getByRole('menuitem', { name: 'Leaf' })).toHaveFocus());
|
||||
expect(changed).not.toHaveBeenCalled();
|
||||
expect(root).toHaveAttribute('data-open');
|
||||
|
||||
await user.keyboard('{Escape}');
|
||||
await waitFor(() => expect(screen.queryByRole('menuitem', { name: 'Leaf' })).toBeNull());
|
||||
expect(more).toHaveFocus();
|
||||
expect(changed).not.toHaveBeenCalled();
|
||||
await user.keyboard('{Escape}');
|
||||
await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
|
||||
expect(changed).toHaveBeenCalledExactlyOnceWith(
|
||||
false,
|
||||
expect.objectContaining({ reason: 'escape-key' }),
|
||||
);
|
||||
expect(root.isConnected).toBe(keepMounted);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it.each([false, true])(
|
||||
'supports an external anchor across reopen, keepMounted=%s',
|
||||
async (keepMounted) => {
|
||||
const changed = vi.fn();
|
||||
function Demo() {
|
||||
const [anchor, setAnchor] = React.useState<HTMLButtonElement | null>(null);
|
||||
return (
|
||||
<React.Fragment>
|
||||
<button type="button" onClick={(event) => setAnchor(event.currentTarget)}>
|
||||
Open
|
||||
</button>
|
||||
<Menu.Root
|
||||
open={Boolean(anchor)}
|
||||
onOpenChange={(open, details) => {
|
||||
changed(open, details.reason);
|
||||
if (!open) {
|
||||
setAnchor(null);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Menu.Portal keepMounted={keepMounted}>
|
||||
<Menu.Positioner anchor={anchor}>
|
||||
<Menu.Popup>
|
||||
<Submenu label="More">
|
||||
<Menu.Item>Nested</Menu.Item>
|
||||
</Submenu>
|
||||
</Menu.Popup>
|
||||
</Menu.Positioner>
|
||||
</Menu.Portal>
|
||||
</Menu.Root>
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
const { user } = await render(<Demo />);
|
||||
const anchor = screen.getByRole('button', { name: 'Open' });
|
||||
async function openAndSelect() {
|
||||
await user.click(anchor);
|
||||
await focusItem('More');
|
||||
await user.keyboard('{ArrowRight}');
|
||||
const nested = await screen.findByRole('menuitem', { name: 'Nested' });
|
||||
await waitFor(() => expect(nested).toHaveFocus());
|
||||
expect(changed).not.toHaveBeenCalled();
|
||||
await user.click(nested);
|
||||
await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
|
||||
expect(changed).toHaveBeenCalledExactlyOnceWith(false, 'item-press');
|
||||
await waitFor(() => expect(anchor).toHaveFocus());
|
||||
changed.mockClear();
|
||||
}
|
||||
await openAndSelect();
|
||||
await openAndSelect();
|
||||
},
|
||||
);
|
||||
|
||||
it.each(['click', 'hover'] as const)(
|
||||
'closes a sibling submenu without closing the root on %s',
|
||||
async (method) => {
|
||||
const changed = vi.fn();
|
||||
const firstChanged = vi.fn();
|
||||
const { user } = await render(
|
||||
<Menu.Root defaultOpen modal={false} onOpenChange={changed}>
|
||||
<Popup>
|
||||
<Submenu label="First" onOpenChange={firstChanged} openOnHover={method === 'hover'}>
|
||||
<Menu.Item>First item</Menu.Item>
|
||||
</Submenu>
|
||||
<Submenu label="Second" openOnHover={method === 'hover'}>
|
||||
<Menu.Item>Second item</Menu.Item>
|
||||
</Submenu>
|
||||
</Popup>
|
||||
</Menu.Root>,
|
||||
);
|
||||
await user[method](await focusItem('First'));
|
||||
await screen.findByRole('menuitem', { name: 'First item' });
|
||||
firstChanged.mockClear();
|
||||
await user[method](screen.getByRole('menuitem', { name: 'Second' }));
|
||||
await screen.findByRole('menuitem', { name: 'Second item' });
|
||||
await waitFor(() =>
|
||||
expect(screen.queryByRole('menuitem', { name: 'First item' })).toBeNull(),
|
||||
);
|
||||
expect(firstChanged).toHaveBeenCalledExactlyOnceWith(
|
||||
false,
|
||||
expect.objectContaining({
|
||||
reason: expect.stringMatching(
|
||||
method === 'hover' ? /^(trigger-hover|sibling-open)$/ : /^sibling-open$/,
|
||||
),
|
||||
}),
|
||||
);
|
||||
expect(changed).not.toHaveBeenCalled();
|
||||
},
|
||||
);
|
||||
|
||||
it('keeps an initially open submenu attached to the root', async () => {
|
||||
const changed = vi.fn();
|
||||
const completed = vi.fn();
|
||||
await render(
|
||||
<Menu.Root defaultOpen modal={false} onOpenChange={changed}>
|
||||
<Popup>
|
||||
<Submenu label="More" defaultOpen onOpenChangeComplete={completed}>
|
||||
<Menu.Item>Nested</Menu.Item>
|
||||
</Submenu>
|
||||
</Popup>
|
||||
</Menu.Root>,
|
||||
);
|
||||
await waitFor(() => expect(completed).toHaveBeenCalledWith(true));
|
||||
expect(screen.getAllByRole('menu')).toHaveLength(2);
|
||||
expect(changed).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it.each([false, true])(
|
||||
'preserves real trigger registration, initially present=%s',
|
||||
async (initialTrigger) => {
|
||||
const changed = vi.fn();
|
||||
const registered = vi.fn();
|
||||
const rootIds = vi.fn();
|
||||
function CaptureTriggerIds() {
|
||||
const { store } = useMenuRootContext();
|
||||
useIsoLayoutEffect(() => {
|
||||
registered(store, store.select('floatingNodeId'), store.select('floatingParentNodeId'));
|
||||
}, [store]);
|
||||
return null;
|
||||
}
|
||||
function Demo() {
|
||||
const [hasTrigger, setHasTrigger] = React.useState(initialTrigger);
|
||||
useIsoLayoutEffect(() => {
|
||||
if (hasTrigger) {
|
||||
const [store, nodeId, parentNodeId] = registered.mock.lastCall!;
|
||||
rootIds(
|
||||
store.select('floatingNodeId'),
|
||||
nodeId,
|
||||
store.select('floatingParentNodeId'),
|
||||
parentNodeId,
|
||||
);
|
||||
}
|
||||
}, [hasTrigger]);
|
||||
return (
|
||||
<Menu.Root defaultOpen modal={false} onOpenChange={changed}>
|
||||
{hasTrigger && (
|
||||
<React.Fragment>
|
||||
<Menu.Trigger>Options</Menu.Trigger>
|
||||
<CaptureTriggerIds />
|
||||
</React.Fragment>
|
||||
)}
|
||||
<Popup>
|
||||
<Menu.SubmenuRoot>
|
||||
<Menu.SubmenuTrigger
|
||||
openOnHover={false}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === 'F2') {
|
||||
setHasTrigger(true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
More
|
||||
</Menu.SubmenuTrigger>
|
||||
<Menu.Portal>
|
||||
<Menu.Positioner>
|
||||
<Menu.Popup>
|
||||
<Menu.Item>Nested</Menu.Item>
|
||||
</Menu.Popup>
|
||||
</Menu.Positioner>
|
||||
</Menu.Portal>
|
||||
</Menu.SubmenuRoot>
|
||||
</Popup>
|
||||
</Menu.Root>
|
||||
);
|
||||
}
|
||||
const { user } = await render(<Demo />);
|
||||
await focusItem('More');
|
||||
await user.keyboard('{F2}');
|
||||
const trigger = screen.getByRole('button', { name: 'Options' });
|
||||
expect(rootIds).toHaveBeenCalled();
|
||||
for (const [nodeId, triggerNodeId, parentNodeId, triggerParentNodeId] of rootIds.mock.calls) {
|
||||
expect(triggerNodeId).toBeDefined();
|
||||
expect(nodeId).toBe(triggerNodeId);
|
||||
expect(parentNodeId).toBe(triggerParentNodeId);
|
||||
}
|
||||
await user.keyboard('{ArrowRight}');
|
||||
await waitFor(() => expect(screen.getByRole('menuitem', { name: 'Nested' })).toHaveFocus());
|
||||
expect(changed).not.toHaveBeenCalled();
|
||||
await user.keyboard('{Escape}');
|
||||
await waitFor(() => expect(screen.queryByRole('menuitem', { name: 'Nested' })).toBeNull());
|
||||
await user.keyboard('{Escape}');
|
||||
await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
|
||||
await waitFor(() => expect(trigger).toHaveFocus());
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -262,7 +262,9 @@ export const MenuRoot = fastComponent(function MenuRoot<Payload>(props: MenuRoot
|
||||
floatingNodeId: floatingNodeIdFromContext,
|
||||
floatingParentNodeId: floatingParentNodeIdFromContext,
|
||||
});
|
||||
} else if (parentMenuRootContext) {
|
||||
} else if (parentMenuRootContext || !store.select('activeTriggerElement')) {
|
||||
// Without an active trigger, the root must supply its own tree IDs.
|
||||
// Read the store here: a trigger can register after render, before this effect.
|
||||
store.update({
|
||||
floatingNodeId: floatingNodeIdFromContext,
|
||||
floatingParentNodeId: floatingParentNodeIdFromContext,
|
||||
@@ -273,6 +275,7 @@ export const MenuRoot = fastComponent(function MenuRoot<Payload>(props: MenuRoot
|
||||
parentMenuRootContext,
|
||||
floatingNodeIdFromContext,
|
||||
floatingParentNodeIdFromContext,
|
||||
activeTriggerElement,
|
||||
store,
|
||||
]);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import * as React from 'react';
|
||||
import { EMPTY_OBJECT } from '@base-ui/utils/empty';
|
||||
import { useDismiss, useHoverFloatingInteraction } from '../../floating-ui-react';
|
||||
import { getTarget } from '../../floating-ui-react/utils';
|
||||
import { closest, getTarget } from '../../floating-ui-react/utils';
|
||||
import type { BaseUIComponentProps, HTMLProps } from '../../internals/types';
|
||||
import { CompositeRoot } from '../../internals/composite/root/CompositeRoot';
|
||||
import {
|
||||
@@ -56,7 +56,8 @@ export const NavigationMenuList = React.forwardRef(function NavigationMenuList(
|
||||
outsidePressEvent: 'intentional',
|
||||
outsidePress(event) {
|
||||
const target = getTarget(event) as HTMLElement | null;
|
||||
const closestNavigationMenuTrigger = target?.closest(
|
||||
const closestNavigationMenuTrigger = closest(
|
||||
target,
|
||||
`[${NAVIGATION_MENU_TRIGGER_IDENTIFIER}]`,
|
||||
);
|
||||
return closestNavigationMenuTrigger === null;
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
useHoverInteractionSharedState,
|
||||
} from '../../floating-ui-react/hooks/useHoverInteractionSharedState';
|
||||
import {
|
||||
closest,
|
||||
contains,
|
||||
getTabbableAfterElement,
|
||||
getNextTabbable,
|
||||
@@ -512,7 +513,7 @@ export const NavigationMenuTrigger = React.forwardRef(function NavigationMenuTri
|
||||
return null;
|
||||
}
|
||||
|
||||
return triggerElementRef.current?.closest('ul') ?? null;
|
||||
return closest(triggerElementRef.current, 'ul');
|
||||
}
|
||||
|
||||
const hoverProps = useHoverReferenceInteraction(context, {
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import * as React from 'react';
|
||||
import { act, fireEvent, screen } from '@mui/internal-test-utils';
|
||||
import { OTPField } from '@base-ui/react/otp-field';
|
||||
import { createRenderer } from '#test-utils';
|
||||
|
||||
vi.mock('@base-ui/utils/platform', async () => {
|
||||
const actual =
|
||||
await vi.importActual<typeof import('@base-ui/utils/platform')>('@base-ui/utils/platform');
|
||||
|
||||
return {
|
||||
...actual,
|
||||
platform: {
|
||||
...actual.platform,
|
||||
os: { ...actual.platform.os, android: true },
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
describe('<OTPField.Input /> Android', () => {
|
||||
const { render } = createRenderer();
|
||||
|
||||
it('commits each change during an IME composition', async () => {
|
||||
const onValueChange = vi.fn();
|
||||
|
||||
await render(
|
||||
<OTPField.Root length={3} validationType="alphanumeric" onValueChange={onValueChange}>
|
||||
<OTPField.Input />
|
||||
<OTPField.Input />
|
||||
<OTPField.Input />
|
||||
</OTPField.Root>,
|
||||
);
|
||||
|
||||
const inputs = screen.getAllByRole<HTMLInputElement>('textbox');
|
||||
|
||||
await act(async () => {
|
||||
inputs[0].focus();
|
||||
});
|
||||
|
||||
fireEvent.compositionStart(inputs[0]);
|
||||
fireEvent.change(inputs[0], { target: { value: 'a' } });
|
||||
|
||||
expect(onValueChange).toHaveBeenCalledTimes(1);
|
||||
expect(onValueChange).toHaveBeenLastCalledWith('a', expect.anything());
|
||||
expect(document.activeElement).toBe(inputs[1]);
|
||||
|
||||
fireEvent.compositionEnd(inputs[0]);
|
||||
|
||||
expect(onValueChange).toHaveBeenCalledTimes(1);
|
||||
expect(inputs.map((input) => input.value)).toEqual(['a', '', '']);
|
||||
});
|
||||
});
|
||||
@@ -7,6 +7,7 @@ import { OTPField } from '@base-ui/react/otp-field';
|
||||
import { Field } from '@base-ui/react/field';
|
||||
import { DirectionProvider } from '@base-ui/react/direction-provider';
|
||||
import { createRenderer, describeConformance, isJSDOM } from '#test-utils';
|
||||
import { REASONS } from '../../internals/reasons';
|
||||
|
||||
describe('<OTPField.Input />', () => {
|
||||
const { render } = createRenderer();
|
||||
@@ -191,6 +192,129 @@ describe('<OTPField.Input />', () => {
|
||||
expect(firstInput.selectionEnd).toBe(1);
|
||||
});
|
||||
|
||||
it('commits an IME composition once on compositionend instead of per intermediate change', async () => {
|
||||
const onValueChange = vi.fn();
|
||||
|
||||
await render(<OTPFieldTest validationType="alphanumeric" onValueChange={onValueChange} />);
|
||||
|
||||
const inputs = screen.getAllByRole<HTMLInputElement>('textbox');
|
||||
const firstInput = inputs[0];
|
||||
|
||||
await act(async () => {
|
||||
firstInput.focus();
|
||||
});
|
||||
|
||||
fireEvent.compositionStart(firstInput);
|
||||
|
||||
// Safari can surface in-progress IME text through `change` as an accumulating string.
|
||||
fireEvent.change(firstInput, { target: { value: 'd' } });
|
||||
fireEvent.change(firstInput, { target: { value: 'dd' } });
|
||||
fireEvent.change(firstInput, { target: { value: 'ddd' } });
|
||||
|
||||
// No value commits while the composition is active; the text is only buffered for display.
|
||||
expect(onValueChange).not.toHaveBeenCalled();
|
||||
expect(inputs.map((input) => input.value)).toEqual(['ddd', '', '', '', '', '']);
|
||||
|
||||
fireEvent.compositionEnd(firstInput, { target: { value: 'ddd' } });
|
||||
|
||||
// The final composed value commits once across three slots, not six.
|
||||
expect(onValueChange).toHaveBeenCalledTimes(1);
|
||||
expect(onValueChange).toHaveBeenLastCalledWith('ddd', expect.anything());
|
||||
expect(inputs.map((input) => input.value)).toEqual(['d', 'd', 'd', '', '', '']);
|
||||
expect(document.activeElement).toBe(inputs[3]);
|
||||
});
|
||||
|
||||
it('reports characters rejected from a committed IME composition', async () => {
|
||||
const onValueChange = vi.fn();
|
||||
const onValueInvalid = vi.fn();
|
||||
|
||||
await render(<OTPFieldTest onValueChange={onValueChange} onValueInvalid={onValueInvalid} />);
|
||||
|
||||
const inputs = screen.getAllByRole<HTMLInputElement>('textbox');
|
||||
const firstInput = inputs[0];
|
||||
|
||||
await act(async () => {
|
||||
firstInput.focus();
|
||||
});
|
||||
|
||||
fireEvent.compositionStart(firstInput);
|
||||
fireEvent.change(firstInput, { target: { value: '1a' } });
|
||||
|
||||
expect(onValueInvalid).not.toHaveBeenCalled();
|
||||
|
||||
fireEvent.compositionEnd(firstInput, { target: { value: '1a' } });
|
||||
|
||||
expect(onValueInvalid).toHaveBeenCalledTimes(1);
|
||||
expect(onValueInvalid.mock.calls[0]?.[0]).toBe('1a');
|
||||
expect(onValueInvalid.mock.calls[0]?.[1].reason).toBe(REASONS.inputChange);
|
||||
expect(onValueChange).toHaveBeenCalledTimes(1);
|
||||
expect(onValueChange).toHaveBeenLastCalledWith('1', expect.anything());
|
||||
expect(inputs.map((input) => input.value)).toEqual(['1', '', '', '', '', '']);
|
||||
expect(document.activeElement).toBe(inputs[1]);
|
||||
});
|
||||
|
||||
it('ignores keyboard commands while a composition is buffered', async () => {
|
||||
const onValueChange = vi.fn();
|
||||
|
||||
await render(
|
||||
<OTPFieldTest
|
||||
validationType="alphanumeric"
|
||||
defaultValue="12"
|
||||
onValueChange={onValueChange}
|
||||
/>,
|
||||
);
|
||||
|
||||
const inputs = screen.getAllByRole<HTMLInputElement>('textbox');
|
||||
const thirdInput = inputs[2];
|
||||
|
||||
await act(async () => {
|
||||
thirdInput.focus();
|
||||
});
|
||||
|
||||
fireEvent.compositionStart(thirdInput);
|
||||
fireEvent.change(thirdInput, { target: { value: 'a' } });
|
||||
|
||||
// iOS Safari fires a real `Backspace` keydown while the IME is still composing.
|
||||
fireEvent.keyDown(thirdInput, { key: 'Backspace' });
|
||||
|
||||
expect(onValueChange).not.toHaveBeenCalled();
|
||||
expect(document.activeElement).toBe(thirdInput);
|
||||
expect(inputs.map((input) => input.value)).toEqual(['1', '2', 'a', '', '', '']);
|
||||
|
||||
// The IME deleted its own text, so the composition ends empty and nothing commits.
|
||||
fireEvent.compositionEnd(thirdInput, { target: { value: '' } });
|
||||
|
||||
expect(onValueChange).not.toHaveBeenCalled();
|
||||
expect(inputs.map((input) => input.value)).toEqual(['1', '2', '', '', '', '']);
|
||||
});
|
||||
|
||||
(['disabled', 'readOnly'] as const).forEach((prop) => {
|
||||
it(`does not commit a composition that ends after the field becomes ${prop}`, async () => {
|
||||
const onValueChange = vi.fn();
|
||||
|
||||
const { setProps } = await render(
|
||||
<OTPFieldTest validationType="alphanumeric" onValueChange={onValueChange} />,
|
||||
);
|
||||
|
||||
const inputs = screen.getAllByRole<HTMLInputElement>('textbox');
|
||||
const firstInput = inputs[0];
|
||||
|
||||
await act(async () => {
|
||||
firstInput.focus();
|
||||
});
|
||||
|
||||
fireEvent.compositionStart(firstInput);
|
||||
fireEvent.change(firstInput, { target: { value: 'abc' } });
|
||||
|
||||
await setProps({ [prop]: true });
|
||||
|
||||
fireEvent.compositionEnd(firstInput, { target: { value: 'abc' } });
|
||||
|
||||
expect(onValueChange).not.toHaveBeenCalled();
|
||||
expect(inputs.map((input) => input.value)).toEqual(['', '', '', '', '', '']);
|
||||
});
|
||||
});
|
||||
|
||||
it('selects the slot value on mousedown', async () => {
|
||||
await render(<OTPFieldTest defaultValue="1" />);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import * as React from 'react';
|
||||
import { SafeReact } from '@base-ui/utils/safeReact';
|
||||
import { warn } from '@base-ui/utils/warn';
|
||||
import { platform } from '@base-ui/utils/platform';
|
||||
import { stopEvent } from '../../floating-ui-react/utils';
|
||||
import { useCompositeListItem } from '../../internals/composite/list/useCompositeListItem';
|
||||
import type { BaseUIComponentProps } from '../../internals/types';
|
||||
@@ -66,6 +67,12 @@ export const OTPFieldInput = React.forwardRef(function OTPFieldInput(
|
||||
const inputRef = React.useRef<HTMLInputElement | null>(null);
|
||||
const direction = useDirection();
|
||||
|
||||
// While an IME composition is active, Safari exposes the in-progress text through `onChange`
|
||||
// as an accumulating string (`d`, then `dd`, then `ddd`). Committing those intermediate values
|
||||
// would treat them as bulk input and fill too many slots, so the text is only buffered here
|
||||
// and committed once on `compositionend`.
|
||||
const [composingValue, setComposingValue] = React.useState<string | null>(null);
|
||||
|
||||
const slotValue = value[index] ?? '';
|
||||
const inputState = getOTPFieldInputState(state, slotValue, index);
|
||||
const slotAriaLabel = externalAriaLabel;
|
||||
@@ -88,9 +95,52 @@ export const OTPFieldInput = React.forwardRef(function OTPFieldInput(
|
||||
}, [index, slotAriaLabel]);
|
||||
}
|
||||
|
||||
function commitValue(
|
||||
rawValue: string,
|
||||
reason: typeof REASONS.inputChange | typeof REASONS.inputPaste,
|
||||
event: React.SyntheticEvent<HTMLInputElement>,
|
||||
) {
|
||||
const [nextDigits, didRejectCharacters] = normalizeOTPValueWithDetails(
|
||||
rawValue,
|
||||
length,
|
||||
validationType,
|
||||
normalizeValue,
|
||||
);
|
||||
|
||||
if (didRejectCharacters) {
|
||||
reportValueInvalid(rawValue, createGenericEventDetails(reason, event.nativeEvent));
|
||||
}
|
||||
|
||||
if (nextDigits === '') {
|
||||
// Typed input edits the slot in place: clear it, or restore its character when every
|
||||
// typed character was rejected. An empty or fully rejected paste changes nothing.
|
||||
if (reason === REASONS.inputChange) {
|
||||
if (rawValue === '') {
|
||||
setValue(
|
||||
removeOTPCharacter(value, index),
|
||||
createChangeEventDetails(REASONS.inputClear, event.nativeEvent),
|
||||
);
|
||||
} else if (slotValue !== '') {
|
||||
event.currentTarget.value = slotValue;
|
||||
event.currentTarget.select();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const committedValue = setValue(
|
||||
replaceOTPValue(value, index, nextDigits, length, validationType, normalizeValue),
|
||||
createChangeEventDetails(reason, event.nativeEvent),
|
||||
);
|
||||
|
||||
if (committedValue != null) {
|
||||
queueFocusInput(Math.min(index + nextDigits.length, length - 1), committedValue);
|
||||
}
|
||||
}
|
||||
|
||||
const inputProps: React.ComponentProps<'input'> = {
|
||||
id: getInputId(index),
|
||||
value: slotValue,
|
||||
value: composingValue ?? slotValue,
|
||||
type: mask ? 'password' : 'text',
|
||||
inputMode,
|
||||
autoComplete: index === 0 ? autoComplete : 'off',
|
||||
@@ -130,60 +180,40 @@ export const OTPFieldInput = React.forwardRef(function OTPFieldInput(
|
||||
|
||||
handleInputBlur(event);
|
||||
},
|
||||
onCompositionStart() {
|
||||
// Some Android keyboards report all text as always-composing, so Android keeps
|
||||
// committing through `onChange`.
|
||||
if (!platform.os.android) {
|
||||
setComposingValue(slotValue);
|
||||
}
|
||||
},
|
||||
onCompositionEnd(event) {
|
||||
if (composingValue == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
setComposingValue(null);
|
||||
|
||||
if (!disabled && !readOnly) {
|
||||
commitValue(event.currentTarget.value, REASONS.inputChange, event);
|
||||
}
|
||||
},
|
||||
onChange(event) {
|
||||
if (event.defaultPrevented || disabled || readOnly) {
|
||||
return;
|
||||
}
|
||||
|
||||
const rawValue = event.currentTarget.value;
|
||||
const [nextDigits, didRejectCharacters] = normalizeOTPValueWithDetails(
|
||||
rawValue,
|
||||
length,
|
||||
validationType,
|
||||
normalizeValue,
|
||||
);
|
||||
|
||||
if (didRejectCharacters) {
|
||||
reportValueInvalid(
|
||||
rawValue,
|
||||
createGenericEventDetails(REASONS.inputChange, event.nativeEvent),
|
||||
);
|
||||
}
|
||||
|
||||
if (nextDigits === '') {
|
||||
if (rawValue === '') {
|
||||
setValue(
|
||||
removeOTPCharacter(value, index),
|
||||
createChangeEventDetails(REASONS.inputClear, event.nativeEvent),
|
||||
);
|
||||
} else if (slotValue !== '') {
|
||||
event.currentTarget.value = slotValue;
|
||||
event.currentTarget.select();
|
||||
}
|
||||
if (composingValue != null) {
|
||||
setComposingValue(event.currentTarget.value);
|
||||
return;
|
||||
}
|
||||
|
||||
const nextValue = replaceOTPValue(
|
||||
value,
|
||||
index,
|
||||
nextDigits,
|
||||
length,
|
||||
validationType,
|
||||
normalizeValue,
|
||||
);
|
||||
|
||||
const committedValue = setValue(
|
||||
nextValue,
|
||||
createChangeEventDetails(REASONS.inputChange, event.nativeEvent),
|
||||
);
|
||||
|
||||
if (committedValue != null) {
|
||||
const nextInput = Math.min(index + nextDigits.length, length - 1);
|
||||
queueFocusInput(nextInput, committedValue);
|
||||
}
|
||||
commitValue(event.currentTarget.value, REASONS.inputChange, event);
|
||||
},
|
||||
onKeyDown(event) {
|
||||
if (event.defaultPrevented || disabled) {
|
||||
// Browsers deliver real key names (such as `Backspace`) for keydowns inside a composition.
|
||||
// The IME owns editing until `compositionend`, so OTP commands must not run on them.
|
||||
if (event.defaultPrevented || disabled || composingValue != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -289,34 +319,7 @@ export const OTPFieldInput = React.forwardRef(function OTPFieldInput(
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
const [nextDigits, didRejectCharacters] = normalizeOTPValueWithDetails(
|
||||
rawValue,
|
||||
length,
|
||||
validationType,
|
||||
normalizeValue,
|
||||
);
|
||||
|
||||
if (didRejectCharacters) {
|
||||
reportValueInvalid(
|
||||
rawValue,
|
||||
createGenericEventDetails(REASONS.inputPaste, event.nativeEvent),
|
||||
);
|
||||
}
|
||||
|
||||
if (nextDigits === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
const committedValue = setValue(
|
||||
replaceOTPValue(value, index, nextDigits, length, validationType, normalizeValue),
|
||||
createChangeEventDetails(REASONS.inputPaste, event.nativeEvent),
|
||||
);
|
||||
|
||||
if (committedValue != null) {
|
||||
const nextInput = Math.min(index + nextDigits.length, length - 1);
|
||||
queueFocusInput(nextInput, committedValue);
|
||||
}
|
||||
commitValue(rawValue, REASONS.inputPaste, event);
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ describe('<Progress.Root />', () => {
|
||||
|
||||
const progressbar = screen.getByRole('progressbar');
|
||||
expect(progressbar).toHaveAttribute('aria-valuenow', String(expectedValue));
|
||||
expect(screen.getByTestId('value')).toHaveTextContent(expected);
|
||||
expect(screen.getByTestId('value').textContent).toBe(expected);
|
||||
expect(getAriaValueText).toHaveBeenLastCalledWith(expected, value);
|
||||
expect(progressbar).toHaveAttribute('aria-valuetext', `${expected} (raw: ${value})`);
|
||||
},
|
||||
|
||||
@@ -650,6 +650,45 @@ describe('<RadioGroup />', () => {
|
||||
});
|
||||
|
||||
describe('should manage arrow key navigation', () => {
|
||||
it.each(['metaKey', 'ctrlKey', 'altKey', 'single'])(
|
||||
'does not select on refocus after an ignored arrow (%s)',
|
||||
async (scenario) => {
|
||||
const onValueChange = vi.fn();
|
||||
|
||||
const { user } = await render(
|
||||
<React.Fragment>
|
||||
<RadioGroup onValueChange={onValueChange}>
|
||||
<Radio.Root value="a" aria-label="A" />
|
||||
<Radio.Root value="b" aria-label="B" disabled={scenario === 'single'} />
|
||||
</RadioGroup>
|
||||
<button>Outside</button>
|
||||
</React.Fragment>,
|
||||
);
|
||||
|
||||
const radio = screen.getByRole('radio', { name: 'A' });
|
||||
|
||||
act(() => radio.focus());
|
||||
|
||||
fireEvent.keyDown(radio, {
|
||||
key: 'ArrowDown',
|
||||
...(scenario === 'single' ? {} : { [scenario]: true }),
|
||||
});
|
||||
|
||||
expect(radio).toHaveFocus();
|
||||
expect(radio).toHaveAttribute('aria-checked', 'false');
|
||||
|
||||
await user.tab();
|
||||
|
||||
expect(screen.getByRole('button', { name: 'Outside' })).toHaveFocus();
|
||||
|
||||
await user.tab({ shift: true });
|
||||
|
||||
expect(radio).toHaveFocus();
|
||||
expect(radio).toHaveAttribute('aria-checked', 'false');
|
||||
expect(onValueChange).not.toHaveBeenCalled();
|
||||
},
|
||||
);
|
||||
|
||||
[
|
||||
['ltr', 'ArrowRight', 'ArrowLeft'],
|
||||
['rtl', 'ArrowLeft', 'ArrowRight'],
|
||||
|
||||
@@ -238,6 +238,7 @@ export const RadioGroup = React.forwardRef(function RadioGroup<Value>(
|
||||
},
|
||||
onBlur(event) {
|
||||
if (!contains(event.currentTarget, event.relatedTarget)) {
|
||||
setTouched(false);
|
||||
setFieldTouched(true);
|
||||
setFocused(false);
|
||||
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import { expect, vi, describe, it } from 'vitest';
|
||||
import { expect, vi, describe, it, afterEach } from 'vitest';
|
||||
import type { CDPSession } from '@vitest/browser-playwright';
|
||||
import { platform } from '@base-ui/utils/platform';
|
||||
import { ownerDocument } from '@base-ui/utils/owner';
|
||||
import { ScrollArea } from '@base-ui/react/scroll-area';
|
||||
import { DirectionProvider } from '@base-ui/react/direction-provider';
|
||||
import { createRenderer, isJSDOM, describeConformance } from '#test-utils';
|
||||
import { act, fireEvent, screen, waitFor } from '@mui/internal-test-utils';
|
||||
import { createRenderer, isJSDOM, describeConformance, waitSingleFrame } from '#test-utils';
|
||||
import { act, fireEvent, flushMicrotasks, screen, waitFor } from '@mui/internal-test-utils';
|
||||
import { SCROLL_TIMEOUT } from '../constants';
|
||||
|
||||
describe('<ScrollArea.Viewport />', () => {
|
||||
@@ -42,47 +45,126 @@ describe('<ScrollArea.Viewport />', () => {
|
||||
});
|
||||
|
||||
describe.skipIf(isJSDOM)('subtree animations', () => {
|
||||
it('recomputes overflow after a subtree animation finishes', async () => {
|
||||
let scrollWidth = 100;
|
||||
let resolveAnimation: () => void = () => {};
|
||||
const finished = new Promise<void>((resolve) => {
|
||||
resolveAnimation = resolve;
|
||||
});
|
||||
const getAnimations = vi.fn(() => [{ finished }] as unknown as Animation[]);
|
||||
afterEach(() => vi.restoreAllMocks());
|
||||
|
||||
await render(
|
||||
<ScrollArea.Root data-testid="root">
|
||||
<ScrollArea.Viewport
|
||||
ref={(node) => {
|
||||
if (node) {
|
||||
Object.defineProperties(node, {
|
||||
clientHeight: { configurable: true, value: 100 },
|
||||
clientWidth: { configurable: true, value: 100 },
|
||||
scrollHeight: { configurable: true, value: 100 },
|
||||
scrollWidth: { configurable: true, get: () => scrollWidth },
|
||||
getAnimations: { configurable: true, value: getAnimations },
|
||||
});
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<ScrollArea.Scrollbar orientation="horizontal" keepMounted>
|
||||
<ScrollArea.Thumb />
|
||||
</ScrollArea.Scrollbar>
|
||||
</ScrollArea.Root>,
|
||||
);
|
||||
it.skipIf(!platform.engine.blink)(
|
||||
'releases a completed animation target while another animation is paused',
|
||||
async () => {
|
||||
const { cdp } = await import('vitest/browser');
|
||||
const session = cdp() as CDPSession;
|
||||
let targetRef: WeakRef<HTMLDivElement> | undefined;
|
||||
let animationsRead = false;
|
||||
|
||||
const root = screen.getByTestId('root');
|
||||
await waitFor(() => expect(getAnimations).toHaveBeenCalled());
|
||||
expect(root).not.toHaveAttribute('data-has-overflow-x');
|
||||
await render(
|
||||
<ScrollArea.Root>
|
||||
<ScrollArea.Viewport
|
||||
data-testid="viewport"
|
||||
ref={(node) => {
|
||||
if (!node || node.firstElementChild) {
|
||||
return;
|
||||
}
|
||||
|
||||
scrollWidth = 1000;
|
||||
await act(async () => {
|
||||
resolveAnimation();
|
||||
await finished;
|
||||
});
|
||||
const target = ownerDocument(node).createElement('div');
|
||||
const pausedTarget = ownerDocument(node).createElement('div');
|
||||
node.append(target, pausedTarget);
|
||||
targetRef = new WeakRef(target);
|
||||
|
||||
await waitFor(() => expect(root).toHaveAttribute('data-has-overflow-x'));
|
||||
});
|
||||
for (const element of [target, pausedTarget]) {
|
||||
element
|
||||
.animate({ opacity: [0, 1] }, { duration: 1000, fill: 'forwards' })
|
||||
.pause();
|
||||
}
|
||||
|
||||
// A spy would retain the Animation objects in its recorded results.
|
||||
const getAnimations = node.getAnimations.bind(node);
|
||||
node.getAnimations = (options) => {
|
||||
animationsRead = true;
|
||||
return getAnimations(options);
|
||||
};
|
||||
}}
|
||||
/>
|
||||
</ScrollArea.Root>,
|
||||
);
|
||||
|
||||
await waitFor(() => expect(animationsRead).toBe(true));
|
||||
|
||||
const viewport = screen.getByTestId('viewport');
|
||||
viewport.firstElementChild!.getAnimations()[0].finish();
|
||||
await act(async () => {
|
||||
await flushMicrotasks();
|
||||
});
|
||||
viewport.firstElementChild!.remove();
|
||||
await waitSingleFrame();
|
||||
|
||||
await session.send('HeapProfiler.collectGarbage');
|
||||
|
||||
expect(targetRef!.deref()).toBeUndefined();
|
||||
expect(viewport.firstElementChild!.getAnimations()[0].playState).toBe('paused');
|
||||
},
|
||||
);
|
||||
|
||||
it.each([
|
||||
['no infinite animation', undefined],
|
||||
['infinite iterations', { iterations: Infinity }],
|
||||
['infinite duration', { duration: Infinity, iterations: 1 }],
|
||||
] as const)(
|
||||
'recomputes overflow after a subtree animation finishes with %s',
|
||||
async (_description, infiniteTiming) => {
|
||||
vi.spyOn(ResizeObserver.prototype, 'observe').mockImplementation(() => {});
|
||||
let scrollWidth = 100;
|
||||
let resolveAnimation: () => void = () => {};
|
||||
const finished = new Promise<void>((resolve) => {
|
||||
resolveAnimation = resolve;
|
||||
});
|
||||
const getAnimations = vi.fn(
|
||||
() =>
|
||||
[
|
||||
{ finished },
|
||||
...(infiniteTiming
|
||||
? [
|
||||
{
|
||||
finished: new Promise<void>(() => {}),
|
||||
effect: { getTiming: () => infiniteTiming },
|
||||
},
|
||||
]
|
||||
: []),
|
||||
] as unknown as Animation[],
|
||||
);
|
||||
|
||||
await render(
|
||||
<ScrollArea.Root data-testid="root">
|
||||
<ScrollArea.Viewport
|
||||
ref={(node) => {
|
||||
if (node) {
|
||||
Object.defineProperties(node, {
|
||||
clientHeight: { configurable: true, value: 100 },
|
||||
clientWidth: { configurable: true, value: 100 },
|
||||
scrollHeight: { configurable: true, value: 100 },
|
||||
scrollWidth: { configurable: true, get: () => scrollWidth },
|
||||
getAnimations: { configurable: true, value: getAnimations },
|
||||
});
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<ScrollArea.Scrollbar orientation="horizontal" keepMounted>
|
||||
<ScrollArea.Thumb />
|
||||
</ScrollArea.Scrollbar>
|
||||
</ScrollArea.Root>,
|
||||
);
|
||||
|
||||
const root = screen.getByTestId('root');
|
||||
await waitFor(() => expect(getAnimations).toHaveBeenCalled());
|
||||
expect(root).not.toHaveAttribute('data-has-overflow-x');
|
||||
|
||||
scrollWidth = 1000;
|
||||
await act(async () => {
|
||||
resolveAnimation();
|
||||
await finished;
|
||||
});
|
||||
|
||||
await waitFor(() => expect(root).toHaveAttribute('data-has-overflow-x'));
|
||||
},
|
||||
);
|
||||
|
||||
it('ignores an animation finishing after its viewport unmounts', async () => {
|
||||
let resolveAnimation: () => void = () => {};
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useIsoLayoutEffect } from '@base-ui/utils/useIsoLayoutEffect';
|
||||
import { platform } from '@base-ui/utils/platform';
|
||||
import { useTimeout } from '@base-ui/utils/useTimeout';
|
||||
import { clamp } from '@base-ui/utils/clamp';
|
||||
import { NOOP } from '@base-ui/utils/empty';
|
||||
import type { BaseUIComponentProps } from '../../internals/types';
|
||||
import { useScrollAreaRootContext } from '../root/ScrollAreaRootContext';
|
||||
import { ScrollAreaViewportContext } from './ScrollAreaViewportContext';
|
||||
@@ -16,6 +17,7 @@ import { styleDisableScrollbar } from '../../utils/styles';
|
||||
import { scrollAreaStateAttributesMapping } from '../root/stateAttributes';
|
||||
import type { HiddenState, ScrollAreaRootState } from '../root/ScrollAreaRoot';
|
||||
import { normalizeScrollOffset } from '../../utils/scrollEdges';
|
||||
import { getFiniteAnimations } from '../../utils/getFiniteAnimations';
|
||||
import * as ScrollAreaViewportCssVars from './ScrollAreaViewportCssVars';
|
||||
import * as ScrollAreaScrollbarCssVars from '../scrollbar/ScrollAreaScrollbarCssVars';
|
||||
|
||||
@@ -336,7 +338,7 @@ export const ScrollAreaViewport = React.forwardRef(function ScrollAreaViewport(
|
||||
// Wait for subtree animations to finish, then recompute thumb geometry that
|
||||
// may have been affected by transform-based animations.
|
||||
waitForAnimationsTimeout.start(0, () => {
|
||||
const animations = viewport.getAnimations({ subtree: true });
|
||||
const animations = getFiniteAnimations(viewport, { subtree: true });
|
||||
if (animations.length === 0) {
|
||||
return;
|
||||
}
|
||||
@@ -344,7 +346,8 @@ export const ScrollAreaViewport = React.forwardRef(function ScrollAreaViewport(
|
||||
// `allSettled` never rejects, but `computeThumbPosition` can still run against a
|
||||
// torn-down tree once the animations resolve. Swallow instead of leaking an unhandled
|
||||
// rejection; `void` alone would only silence the floating-promise lint.
|
||||
Promise.allSettled(animations.map((animation) => animation.finished))
|
||||
// Discard fulfilled Animation values so unfinished animations cannot retain their targets.
|
||||
Promise.allSettled(animations.map((animation) => animation.finished.then(NOOP)))
|
||||
.then(computeThumbPosition)
|
||||
.catch(() => {});
|
||||
});
|
||||
|
||||
@@ -233,6 +233,28 @@ function App3() {
|
||||
);
|
||||
}
|
||||
|
||||
function ReadonlyMultipleValues() {
|
||||
const [value, setValue] = React.useState<string[]>([]);
|
||||
const readonlyValue: readonly string[] = value;
|
||||
const tupleValue = ['javascript', 'typescript'] as const;
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Select.Root multiple value={readonlyValue} onValueChange={setValue} />
|
||||
<Select.Root multiple defaultValue={readonlyValue} onValueChange={setValue} />
|
||||
<Select.Root
|
||||
multiple
|
||||
value={tupleValue}
|
||||
onValueChange={(newValue) => {
|
||||
expectType<('javascript' | 'typescript')[], typeof newValue>(newValue);
|
||||
newValue.pop();
|
||||
}}
|
||||
/>
|
||||
<Select.Root multiple defaultValue={tupleValue} onValueChange={setValue} />
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
mergeProps<typeof Select.Root<any>>(
|
||||
{
|
||||
value: '',
|
||||
|
||||
@@ -574,7 +574,11 @@ export function SelectRoot<Value, Multiple extends boolean | undefined = false>(
|
||||
);
|
||||
}
|
||||
|
||||
type SelectValueType<Value, Multiple extends boolean | undefined> = Multiple extends true
|
||||
type SelectInputValue<Value, Multiple extends boolean | undefined> = Multiple extends true
|
||||
? readonly Value[]
|
||||
: Value;
|
||||
|
||||
type SelectOutputValue<Value, Multiple extends boolean | undefined> = Multiple extends true
|
||||
? Value[]
|
||||
: Value;
|
||||
|
||||
@@ -701,17 +705,17 @@ export interface SelectRootProps<Value, Multiple extends boolean | undefined = f
|
||||
*
|
||||
* To render a controlled select, use the `value` prop instead.
|
||||
*/
|
||||
defaultValue?: SelectValueType<Value, Multiple> | null | undefined;
|
||||
defaultValue?: SelectInputValue<Value, Multiple> | null | undefined;
|
||||
/**
|
||||
* The value of the select. Use when controlled.
|
||||
*/
|
||||
value?: SelectValueType<Value, Multiple> | null | undefined;
|
||||
value?: SelectInputValue<Value, Multiple> | null | undefined;
|
||||
/**
|
||||
* Event handler called when the value of the select changes.
|
||||
*/
|
||||
onValueChange?:
|
||||
| ((
|
||||
value: SelectValueType<Value, Multiple> | (Multiple extends true ? never : null),
|
||||
value: SelectOutputValue<Value, Multiple> | (Multiple extends true ? never : null),
|
||||
eventDetails: SelectRootChangeEventDetails,
|
||||
) => void)
|
||||
| undefined;
|
||||
|
||||
@@ -6,7 +6,7 @@ import { ownerDocument } from '@base-ui/utils/owner';
|
||||
import { inertValue } from '@base-ui/utils/inertValue';
|
||||
import { useIsoLayoutEffect } from '@base-ui/utils/useIsoLayoutEffect';
|
||||
import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
||||
import { activeElement, contains, getTarget } from '../../floating-ui-react/utils';
|
||||
import { activeElement, closest, contains, getTarget } from '../../floating-ui-react/utils';
|
||||
import type { BaseUIComponentProps, HTMLProps } from '../../internals/types';
|
||||
import type { ToastObject as ToastObjectType } from '../useToastManager';
|
||||
import { ToastRootContext } from './ToastRootContext';
|
||||
@@ -248,7 +248,8 @@ export const ToastRoot = React.forwardRef(function ToastRoot(
|
||||
|
||||
const target = getTarget(event.nativeEvent) as HTMLElement | null;
|
||||
|
||||
const isInteractiveElement = target?.closest(
|
||||
const isInteractiveElement = closest(
|
||||
target,
|
||||
`button,a,input,textarea,[role="button"],${TOAST_SWIPE_IGNORE_SELECTOR}`,
|
||||
);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
useFocus,
|
||||
useHoverReferenceInteraction,
|
||||
} from '../../floating-ui-react';
|
||||
import { contains } from '../../floating-ui-react/utils/element';
|
||||
import { closest, contains } from '../../floating-ui-react/utils/element';
|
||||
import { isMouseLikePointerType } from '../../floating-ui-react/utils/event';
|
||||
import { createChangeEventDetails } from '../../internals/createBaseUIEventDetails';
|
||||
import { REASONS } from '../../internals/reasons';
|
||||
@@ -49,21 +49,6 @@ function getTargetElement(event: Event): Element | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
function closestEnabledTooltipTrigger(element: Element | null): Element | null {
|
||||
let current = element;
|
||||
while (current) {
|
||||
const trigger = current.closest(`[${TOOLTIP_TRIGGER_IDENTIFIER}]`);
|
||||
if (trigger) {
|
||||
return trigger;
|
||||
}
|
||||
|
||||
const root = current.getRootNode();
|
||||
current = 'host' in root && isElement(root.host) ? root.host : null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* An element to attach the tooltip to.
|
||||
* Renders a `<button>` element.
|
||||
@@ -153,7 +138,7 @@ export const TooltipTrigger = fastComponentRef(function TooltipTrigger(
|
||||
return false;
|
||||
}
|
||||
|
||||
const nearestTrigger = closestEnabledTooltipTrigger(target);
|
||||
const nearestTrigger = closest(target, `[${TOOLTIP_TRIGGER_IDENTIFIER}]`);
|
||||
return (
|
||||
nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger)
|
||||
);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Excludes infinite animations, whose finished promises never resolve while they run.
|
||||
*/
|
||||
export function getFiniteAnimations(element: Element, options?: GetAnimationsOptions): Animation[] {
|
||||
return element.getAnimations(options).filter((animation) => {
|
||||
const timing = animation.effect?.getTiming();
|
||||
return timing?.duration !== Infinity && timing?.iterations !== Infinity;
|
||||
});
|
||||
}
|
||||
@@ -84,13 +84,15 @@ function TestForwardedTrigger({
|
||||
id,
|
||||
store,
|
||||
element,
|
||||
payload,
|
||||
}: {
|
||||
id: string;
|
||||
store: ReactStore<PopupStoreState<unknown>, PopupStoreContext<unknown>, PopupStoreSelectors>;
|
||||
element: HTMLElement;
|
||||
payload?: unknown;
|
||||
}) {
|
||||
const elementRef = React.useRef<Element | null>(null);
|
||||
const { registerTrigger } = useTriggerDataForwarding(id, elementRef, store, {});
|
||||
const { registerTrigger } = useTriggerDataForwarding(id, elementRef, store, { payload });
|
||||
|
||||
useIsoLayoutEffect(() => {
|
||||
elementRef.current = element;
|
||||
@@ -415,6 +417,86 @@ describe('useTriggerRegistration', () => {
|
||||
expect(store.state.activeTriggerElement).toBe(element);
|
||||
});
|
||||
|
||||
it('does not claim the only registered trigger when the popup opened without a trigger', () => {
|
||||
const store = createStore();
|
||||
const element = document.createElement('button');
|
||||
|
||||
render(
|
||||
<React.Fragment>
|
||||
<ImplicitActiveTriggerTest store={store} />
|
||||
<TestTrigger id="trigger" store={store} element={element} />
|
||||
</React.Fragment>,
|
||||
);
|
||||
|
||||
act(() => {
|
||||
store.update(createPopupOpenState(store.state, true, undefined));
|
||||
});
|
||||
|
||||
expect(store.state.triggerCount).toBe(1);
|
||||
expect(store.state.openedWithoutTrigger).toBe(true);
|
||||
expect(store.state.activeTriggerId).toBe(null);
|
||||
expect(store.state.activeTriggerElement).toBe(null);
|
||||
});
|
||||
|
||||
it('claims the only registered trigger again after a trigger-less open is closed by a controlled prop', () => {
|
||||
const store = createStore();
|
||||
const element = document.createElement('button');
|
||||
|
||||
render(
|
||||
<React.Fragment>
|
||||
<ImplicitActiveTriggerTest store={store} />
|
||||
<TestTrigger id="trigger" store={store} element={element} />
|
||||
</React.Fragment>,
|
||||
);
|
||||
|
||||
act(() => {
|
||||
store.update(createPopupOpenState(store.state, true, undefined));
|
||||
});
|
||||
expect(store.state.activeTriggerId).toBe(null);
|
||||
|
||||
// A controlled close bypasses `createPopupOpenState`, so the root clears the flag itself.
|
||||
act(() => {
|
||||
store.set('open', false);
|
||||
});
|
||||
expect(store.state.openedWithoutTrigger).toBe(false);
|
||||
|
||||
act(() => {
|
||||
store.set('open', true);
|
||||
});
|
||||
expect(store.state.activeTriggerId).toBe('trigger');
|
||||
expect(store.state.activeTriggerElement).toBe(element);
|
||||
});
|
||||
|
||||
it('does not let a trigger registering into an open trigger-less popup claim it', () => {
|
||||
const store = createStore();
|
||||
const element = document.createElement('button');
|
||||
store.set('payload', 'programmatic');
|
||||
store.update(createPopupOpenState(store.state, true, undefined));
|
||||
|
||||
render(
|
||||
<TestForwardedTrigger id="trigger" store={store} element={element} payload="from trigger" />,
|
||||
);
|
||||
|
||||
expect(store.context.triggerElements.getById('trigger')).toBe(element);
|
||||
expect(store.state.activeTriggerId).toBe(null);
|
||||
expect(store.state.activeTriggerElement).toBe(null);
|
||||
expect(store.state.payload).toBe('programmatic');
|
||||
});
|
||||
|
||||
it('lets a trigger registering into a popup opened by a controlled prop claim it', () => {
|
||||
const store = createStore();
|
||||
const element = document.createElement('button');
|
||||
store.set('open', true);
|
||||
|
||||
render(
|
||||
<TestForwardedTrigger id="trigger" store={store} element={element} payload="from trigger" />,
|
||||
);
|
||||
|
||||
expect(store.state.activeTriggerId).toBe('trigger');
|
||||
expect(store.state.activeTriggerElement).toBe(element);
|
||||
expect(store.state.payload).toBe('from trigger');
|
||||
});
|
||||
|
||||
it('closes when an implicitly claimed trigger unmounts during the claim commit', async () => {
|
||||
const store = createStore();
|
||||
const element = document.createElement('button');
|
||||
@@ -794,6 +876,16 @@ describe('popupId selector', () => {
|
||||
|
||||
expect(store.select('popupId')).toBe('explicit-popup-id');
|
||||
});
|
||||
|
||||
it('associates a lone trigger with the popup id unless the popup opened without a trigger', () => {
|
||||
const store = createStore();
|
||||
|
||||
store.update({ open: true, floatingId: 'popup-id', triggerCount: 1 });
|
||||
expect(store.select('triggerPopupId', 'trigger')).toBe('popup-id');
|
||||
|
||||
store.set('openedWithoutTrigger', true);
|
||||
expect(store.select('triggerPopupId', 'trigger')).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('usePopupInteractionProps', () => {
|
||||
@@ -857,6 +949,24 @@ describe('getPopupOpenState', () => {
|
||||
expect(nextState.activeTriggerId).toBe('trigger-id');
|
||||
expect(nextState.activeTriggerElement).toBe(trigger);
|
||||
});
|
||||
|
||||
it('records whether an open request carried a trigger', () => {
|
||||
const state = createInitialPopupStoreState(new PopupTriggerMap());
|
||||
const trigger = document.createElement('button');
|
||||
trigger.id = 'trigger-id';
|
||||
|
||||
expect(createPopupOpenState(state, true, undefined).openedWithoutTrigger).toBe(true);
|
||||
expect(createPopupOpenState(state, true, trigger).openedWithoutTrigger).toBe(false);
|
||||
});
|
||||
|
||||
it('keeps the trigger-less open flag through a close request', () => {
|
||||
// A controlled root may decline the close and stay open; the Root resets the flag itself once
|
||||
// the popup is effectively closed.
|
||||
const state = createInitialPopupStoreState(new PopupTriggerMap());
|
||||
state.openedWithoutTrigger = true;
|
||||
|
||||
expect(createPopupOpenState(state, false, undefined).openedWithoutTrigger).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('applyPopupOpenChange', () => {
|
||||
|
||||
@@ -184,7 +184,11 @@ export function useTriggerRegistration<State extends PopupStoreState<unknown>>(
|
||||
|
||||
type PopupOpenState = Pick<
|
||||
PopupStoreState<unknown>,
|
||||
'open' | 'preventUnmountingOnClose' | 'activeTriggerId' | 'activeTriggerElement'
|
||||
| 'open'
|
||||
| 'preventUnmountingOnClose'
|
||||
| 'activeTriggerId'
|
||||
| 'activeTriggerElement'
|
||||
| 'openedWithoutTrigger'
|
||||
>;
|
||||
|
||||
export function createPopupOpenState(
|
||||
@@ -217,6 +221,12 @@ export function createPopupOpenState(
|
||||
preventUnmountingOnClose,
|
||||
activeTriggerId,
|
||||
activeTriggerElement,
|
||||
// An open request without a trigger (a handle's `open(null)` or `openWithPayload()`) must not
|
||||
// be reassociated with a lone registered trigger later on. Controlled and default opens never
|
||||
// pass through here, so they keep claiming a lone trigger. A close request keeps the flag: a
|
||||
// controlled root may decline it and stay open, so the Root clears the flag only once the
|
||||
// popup is effectively closed.
|
||||
openedWithoutTrigger: open ? trigger == null : state.openedWithoutTrigger,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -344,10 +354,11 @@ export function useTriggerDataForwarding<
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeTriggerId == null && open) {
|
||||
if (activeTriggerId == null && open && !store.state.openedWithoutTrigger) {
|
||||
// If a popup is already open, a detached trigger can mount before any active trigger
|
||||
// has been established. Claim the first registered trigger so trigger-owned focus
|
||||
// management and ARIA relationships work.
|
||||
// management and ARIA relationships work. A popup opened deliberately without a trigger
|
||||
// stays unassociated so the trigger's `payload` does not replace the programmatic one.
|
||||
const changes = {
|
||||
activeTriggerId: triggerId ?? null,
|
||||
activeTriggerElement: element,
|
||||
@@ -395,7 +406,8 @@ export type PayloadChildRenderFunction<Payload> = (arg: {
|
||||
* Keeps trigger registration state synchronized while the popup is open.
|
||||
*
|
||||
* When a popup opens without an explicit trigger id and exactly one trigger is registered, that
|
||||
* trigger is claimed as the active trigger. When the active trigger id is still registered but its
|
||||
* trigger is claimed as the active trigger, unless the open request deliberately carried no trigger
|
||||
* (`openedWithoutTrigger`). When the active trigger id is still registered but its
|
||||
* element changed, the active element is refreshed. When the active trigger id is missing from the
|
||||
* registry but the same element is still registered under a different id (e.g. the rendered trigger
|
||||
* carries its own DOM `id` that differs from Base UI's internal trigger id), the active id is
|
||||
@@ -440,6 +452,12 @@ export function useImplicitActiveTrigger<State extends PopupStoreState<unknown>>
|
||||
if (store.state.triggerCount !== 0) {
|
||||
store.set('triggerCount', 0);
|
||||
}
|
||||
// The flag is cleared only here, once the popup is effectively closed: a controlled root may
|
||||
// decline a close request and stay open, and a controlled close never reaches
|
||||
// `createPopupOpenState` at all.
|
||||
if (store.state.openedWithoutTrigger) {
|
||||
store.set('openedWithoutTrigger', false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -485,7 +503,12 @@ export function useImplicitActiveTrigger<State extends PopupStoreState<unknown>>
|
||||
resolvedActiveTriggerIdRef.current = null;
|
||||
}
|
||||
|
||||
if (!lostActiveTriggerId && !currentActiveTriggerId && triggerCount === 1) {
|
||||
if (
|
||||
!lostActiveTriggerId &&
|
||||
!currentActiveTriggerId &&
|
||||
!store.state.openedWithoutTrigger &&
|
||||
triggerCount === 1
|
||||
) {
|
||||
const iteratorResult = store.context.triggerElements.entries().next();
|
||||
if (!iteratorResult.done) {
|
||||
const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
|
||||
|
||||
@@ -53,6 +53,13 @@ export type PopupStoreState<Payload> = {
|
||||
* The currently active trigger DOM element.
|
||||
*/
|
||||
activeTriggerElement: Element | null;
|
||||
/**
|
||||
* Whether the popup is open because of a request that deliberately carried no trigger, such as a
|
||||
* handle's `open(null)` or `openWithPayload()`. While set, a lone registered trigger is not
|
||||
* implicitly associated with the popup, so its trigger-owned state (such as `payload`) is not
|
||||
* forwarded. Reset by the Root once the popup is effectively closed.
|
||||
*/
|
||||
openedWithoutTrigger: boolean;
|
||||
/**
|
||||
* ID of the trigger (external prop).
|
||||
*/
|
||||
@@ -107,6 +114,7 @@ export function createInitialPopupStoreState<Payload>(
|
||||
payload: undefined,
|
||||
activeTriggerId: null,
|
||||
activeTriggerElement: null,
|
||||
openedWithoutTrigger: false,
|
||||
triggerIdProp: undefined,
|
||||
popupElement: null,
|
||||
positionerElement: null,
|
||||
@@ -161,6 +169,7 @@ function triggerOwnsOpenPopupOrIsOnlyTrigger(state: S, triggerId: string | undef
|
||||
triggerId !== undefined &&
|
||||
openSelector(state) &&
|
||||
activeTriggerIdSelector(state) == null &&
|
||||
!state.openedWithoutTrigger &&
|
||||
state.triggerCount === 1
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
'use client';
|
||||
import * as React from 'react';
|
||||
import { clamp } from '@base-ui/utils/clamp';
|
||||
import { useStableCallback } from '@base-ui/utils/useStableCallback';
|
||||
import { ownerDocument } from '@base-ui/utils/owner';
|
||||
import { clamp } from '@base-ui/utils/clamp';
|
||||
import { contains, getTarget } from '../floating-ui-react/utils';
|
||||
import { closest, contains, getTarget } from '../floating-ui-react/utils';
|
||||
import { findScrollableTouchTarget, hasScrollableAncestor, type ScrollAxis } from './scrollable';
|
||||
import { getElementAtPoint } from './getElementAtPoint';
|
||||
import { getElementTransform } from './getElementTransform';
|
||||
@@ -374,7 +374,7 @@ export function useSwipeDismiss(options: UseSwipeDismissOptions): UseSwipeDismis
|
||||
}
|
||||
swipeFromScrollableRef.current = Boolean(scrollableTarget && ignoreScrollableTarget);
|
||||
|
||||
const isInteractiveElement = target ? target.closest(ignoreSelector) : false;
|
||||
const isInteractiveElement = closest(target, ignoreSelector);
|
||||
if (isInteractiveElement && (!touchLike || ignoreSelectorWhenTouch)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -30,14 +30,14 @@
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.29.7",
|
||||
"@floating-ui/utils": "^0.2.12",
|
||||
"reselect": "^5.2.0",
|
||||
"reselect": "^5.3.0",
|
||||
"use-sync-external-store": "^1.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@testing-library/react": "16.3.2",
|
||||
"@testing-library/user-event": "14.6.3",
|
||||
"@types/react": "19.2.18",
|
||||
"@types/react-dom": "19.2.4",
|
||||
"@types/react-dom": "19.2.7",
|
||||
"@types/use-sync-external-store": "1.5.0",
|
||||
"react": "19.2.8",
|
||||
"react-dom": "19.2.8",
|
||||
|
||||
@@ -1,32 +1,103 @@
|
||||
import { expect, describe, it } from 'vitest';
|
||||
import { getTarget } from './shadowDom';
|
||||
import { expect, describe, it, afterEach, vi } from 'vitest';
|
||||
import { closest, getTarget } from './shadowDom';
|
||||
|
||||
describe('getTarget', () => {
|
||||
it('returns the composed-path target while the event is being dispatched', () => {
|
||||
const parent = document.createElement('div');
|
||||
const child = document.createElement('span');
|
||||
parent.appendChild(child);
|
||||
document.body.appendChild(parent);
|
||||
afterEach(() => {
|
||||
document.body.innerHTML = '';
|
||||
});
|
||||
|
||||
let target: EventTarget | null = null;
|
||||
parent.addEventListener('click', (event) => {
|
||||
target = getTarget(event);
|
||||
describe('shadow DOM utilities', () => {
|
||||
describe('closest', () => {
|
||||
it('finds an ancestor across nested shadow roots from a non-Element node', () => {
|
||||
const button = document.createElement('button');
|
||||
const outerHost = document.createElement('span');
|
||||
const innerHost = document.createElement('span');
|
||||
const target = document.createTextNode('target');
|
||||
|
||||
document.body.appendChild(button);
|
||||
button.appendChild(outerHost);
|
||||
outerHost.attachShadow({ mode: 'open' }).appendChild(innerHost);
|
||||
innerHost.attachShadow({ mode: 'open' }).appendChild(target);
|
||||
|
||||
expect(closest(target, 'button')).toBe(button);
|
||||
});
|
||||
child.dispatchEvent(new Event('click', { bubbles: true }));
|
||||
|
||||
expect(target).toBe(child);
|
||||
parent.remove();
|
||||
it('follows the composed tree through slots', () => {
|
||||
const host = document.createElement('span');
|
||||
const target = document.createElement('span');
|
||||
const shadowAncestor = document.createElement('div');
|
||||
const slot = document.createElement('slot');
|
||||
|
||||
shadowAncestor.dataset.testid = 'shadow-ancestor';
|
||||
shadowAncestor.appendChild(slot);
|
||||
host.attachShadow({ mode: 'open' }).appendChild(shadowAncestor);
|
||||
host.appendChild(target);
|
||||
document.body.appendChild(host);
|
||||
|
||||
expect(closest(target, '[data-testid="shadow-ancestor"]')).toBe(shadowAncestor);
|
||||
});
|
||||
|
||||
it('returns null for a detached node instead of falling back to the document element', () => {
|
||||
document.documentElement.classList.add('match');
|
||||
const element = document.createElement('div');
|
||||
|
||||
expect(closest(element, '.match')).toBeNull();
|
||||
document.documentElement.classList.remove('match');
|
||||
});
|
||||
|
||||
it('preserves native selector validation', () => {
|
||||
const element = document.createElement('div');
|
||||
|
||||
expect(() => closest(element, '[')).toThrow();
|
||||
});
|
||||
|
||||
it('finds an interactive ancestor outside a composed event target shadow root', () => {
|
||||
const button = document.createElement('button');
|
||||
let matchedElement: Element | null = null;
|
||||
const listener = vi.fn((event: PointerEvent) => {
|
||||
matchedElement = closest(getTarget(event) as Node, 'button');
|
||||
});
|
||||
const host = document.createElement('span');
|
||||
const target = document.createElement('span');
|
||||
|
||||
document.body.appendChild(button);
|
||||
button.appendChild(host);
|
||||
host.attachShadow({ mode: 'open' }).appendChild(target);
|
||||
button.addEventListener('pointerdown', listener);
|
||||
|
||||
target.dispatchEvent(new PointerEvent('pointerdown', { bubbles: true, composed: true }));
|
||||
|
||||
expect(listener).toHaveBeenCalledOnce();
|
||||
expect(matchedElement).toBe(button);
|
||||
});
|
||||
});
|
||||
|
||||
it('falls back to `target` once dispatch has completed', () => {
|
||||
const element = document.createElement('div');
|
||||
document.body.appendChild(element);
|
||||
describe('getTarget', () => {
|
||||
it('returns the composed-path target while the event is being dispatched', () => {
|
||||
const parent = document.createElement('div');
|
||||
const child = document.createElement('span');
|
||||
parent.appendChild(child);
|
||||
document.body.appendChild(parent);
|
||||
|
||||
const event = new Event('click');
|
||||
element.dispatchEvent(event);
|
||||
let target: EventTarget | null = null;
|
||||
parent.addEventListener('click', (event) => {
|
||||
target = getTarget(event);
|
||||
});
|
||||
child.dispatchEvent(new Event('click', { bubbles: true }));
|
||||
|
||||
expect(event.composedPath()).toHaveLength(0);
|
||||
expect(getTarget(event)).toBe(element);
|
||||
element.remove();
|
||||
expect(target).toBe(child);
|
||||
parent.remove();
|
||||
});
|
||||
|
||||
it('falls back to `target` once dispatch has completed', () => {
|
||||
const element = document.createElement('div');
|
||||
document.body.appendChild(element);
|
||||
|
||||
const event = new Event('click');
|
||||
element.dispatchEvent(event);
|
||||
|
||||
expect(event.composedPath()).toHaveLength(0);
|
||||
expect(getTarget(event)).toBe(element);
|
||||
element.remove();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
import { isShadowRoot } from '@floating-ui/utils/dom';
|
||||
import { isElement, isShadowRoot } from '@floating-ui/utils/dom';
|
||||
|
||||
export function activeElement(doc: Document) {
|
||||
let element = doc.activeElement;
|
||||
@@ -36,6 +36,39 @@ export function contains(parent?: Element | null, child?: Element | null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the closest matching element in the composed tree, crossing slots and shadow roots.
|
||||
* `:scope` is not supported.
|
||||
*/
|
||||
export function closest<K extends keyof HTMLElementTagNameMap>(
|
||||
node: Node | null | undefined,
|
||||
selector: K,
|
||||
): HTMLElementTagNameMap[K] | null;
|
||||
export function closest<K extends keyof SVGElementTagNameMap>(
|
||||
node: Node | null | undefined,
|
||||
selector: K,
|
||||
): SVGElementTagNameMap[K] | null;
|
||||
export function closest<E extends Element = Element>(
|
||||
node: Node | null | undefined,
|
||||
selector: string,
|
||||
): E | null;
|
||||
export function closest(node: Node | null | undefined, selector: string): Element | null {
|
||||
let current = node;
|
||||
|
||||
while (current) {
|
||||
if (isElement(current) && current.matches(selector)) {
|
||||
return current;
|
||||
}
|
||||
|
||||
current =
|
||||
(current as Element).assignedSlot ??
|
||||
current.parentNode ??
|
||||
(isShadowRoot(current) ? current.host : null);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export function getTarget(event: Event) {
|
||||
if ('composedPath' in event) {
|
||||
// The composed path is empty once the event is no longer being dispatched,
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { expect, describe, it } from 'vitest';
|
||||
import { createRenderer, screen } from '@mui/internal-test-utils';
|
||||
import { isJSDOM } from './testUtils';
|
||||
import { visuallyHidden } from './visuallyHidden';
|
||||
|
||||
describe.skipIf(isJSDOM)('visuallyHidden', () => {
|
||||
const { render } = createRenderer();
|
||||
|
||||
it.each([
|
||||
['ltr', 'ltr'],
|
||||
['ltr', 'rtl'],
|
||||
['rtl', 'ltr'],
|
||||
['rtl', 'rtl'],
|
||||
])(
|
||||
'does not overflow a %s scroller with %s content',
|
||||
async (scrollerDirection, contentDirection) => {
|
||||
await render(
|
||||
<div
|
||||
data-testid="scroller"
|
||||
dir={scrollerDirection}
|
||||
style={{ width: 100, height: 100, overflow: 'auto' }}
|
||||
>
|
||||
{/* Establish a fixed-position containing block below the scroller's top edge. */}
|
||||
<div dir={contentDirection} style={{ transform: 'translateY(20px)' }}>
|
||||
<input type="radio" style={visuallyHidden} />
|
||||
</div>
|
||||
</div>,
|
||||
);
|
||||
|
||||
const scroller = screen.getByTestId('scroller');
|
||||
expect(scroller.scrollWidth).toBe(scroller.clientWidth);
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -14,6 +14,7 @@ const visuallyHiddenBase: React.CSSProperties = {
|
||||
export const visuallyHidden: React.CSSProperties = {
|
||||
...visuallyHiddenBase,
|
||||
position: 'fixed',
|
||||
margin: 0,
|
||||
top: 0,
|
||||
left: 0,
|
||||
};
|
||||
|
||||
@@ -9,26 +9,26 @@
|
||||
"serve": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"radix-ui": "^1.4.3",
|
||||
"radix-ui": "^1.6.7",
|
||||
"react": "19.2.8",
|
||||
"react-dom": "19.2.8",
|
||||
"react-router": "7.18.2"
|
||||
"react-router": "8.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "10.0.1",
|
||||
"@tailwindcss/vite": "4.2.4",
|
||||
"@tailwindcss/vite": "4.3.3",
|
||||
"@types/node": "22.20.1",
|
||||
"@types/react": "19.2.18",
|
||||
"@types/react-dom": "19.2.4",
|
||||
"@vitejs/plugin-react": "6.0.5",
|
||||
"@types/react-dom": "19.2.7",
|
||||
"@vitejs/plugin-react": "6.1.1",
|
||||
"cross-env": "10.1.0",
|
||||
"eslint": "10.8.1",
|
||||
"eslint": "10.10.0",
|
||||
"eslint-plugin-react-hooks": "7.1.1",
|
||||
"eslint-plugin-react-refresh": "0.5.4",
|
||||
"globals": "17.9.0",
|
||||
"tailwindcss": "4.2.4",
|
||||
"typescript": "6.0.3",
|
||||
"typescript-eslint": "8.67.0",
|
||||
"vite": "8.2.1"
|
||||
"eslint-plugin-react-refresh": "0.5.6",
|
||||
"globals": "17.12.0",
|
||||
"tailwindcss": "4.3.3",
|
||||
"typescript": "7.0.2",
|
||||
"typescript-eslint": "8.70.0",
|
||||
"vite": "8.2.2"
|
||||
}
|
||||
}
|
||||
Generated
+2520
-2896
File diff suppressed because it is too large.
Load diff
+11
-9
@@ -33,24 +33,24 @@ overrides:
|
||||
# via nx -> axios (GHSA-hmw2-7cc7-3qxx)
|
||||
form-data: '^4.0.6'
|
||||
# via @microsoft/api-extractor, html-validate, webpack -> ajv (GHSA-4c8g-83qw-93j6, -v2hh-gcrm-f6hx, -7p8r-x3mc-p8w7)
|
||||
fast-uri: '^3.1.5'
|
||||
fast-uri: '^4.1.4'
|
||||
# via lerna -> make-fetch-happen -> socks (GHSA-mwp4-54f8-5fhr, -22jq-vg5j-6vgg, -4xrf-jv44-h6hh)
|
||||
ip-address: '^10.5.0'
|
||||
ip-address: '^10.7.0'
|
||||
# via lerna/stylelint -> cosmiconfig (GHSA-5p4m-2wfm-xmqj, -52cp-r559-cp3m, -h67p-54hq-rp68)
|
||||
js-yaml@4: '^4.3.1'
|
||||
js-yaml@4: '^5.4.2'
|
||||
# via postcss (GHSA-2v37-7h3g-55p8)
|
||||
nanoid@3: '^3.3.18'
|
||||
nanoid@3: '^6.0.1'
|
||||
# via lerna; also picks up the fixed axios and tmp (GHSA-vp3h-ghgh-jr7g)
|
||||
nx: '~22.7.8'
|
||||
nx: '~23.2.1'
|
||||
# via test/bundle-size -> @mui/internal-bundle-size-checker (GHSA-x9g3-xrwr-cwfg)
|
||||
piscina: '^5.3.0'
|
||||
piscina: '^5.3.2'
|
||||
# next pins 8.4.31 (GHSA-6g55-p6wh-862q, -r28c-9q8g-f849, -fxqj-rqcc-2cmp)
|
||||
postcss: '^8.5.26'
|
||||
postcss: '^8.5.28'
|
||||
# optional dependency of next; unused because the docs site is a static export with no next/image
|
||||
sharp: '^0.35.3'
|
||||
sharp: '^0.35.4'
|
||||
# via lerna -> pacote/libnpmpublish; also picks up the fixed @sigstore/core and @sigstore/verify.
|
||||
# Capped below 5, whose engines.node excludes the Node 24.14 line CI runs on.
|
||||
sigstore: '^4.1.1'
|
||||
sigstore: '^5.0.0'
|
||||
# lerna pins 7.5.11 (GHSA-23hp-3jrh-7fpw, -vmf3-w455-68vh, -w8wr-v893-vjvp)
|
||||
tar: '^7.5.22'
|
||||
# via @vitest/browser (GHSA-96hv-2xvq-fx4p)
|
||||
@@ -62,6 +62,8 @@ minimumReleaseAge: 4320
|
||||
minimumReleaseAgeExclude:
|
||||
- '@base-ui/*'
|
||||
- '@mui/internal-*'
|
||||
# Renovate security update: js-yaml@4.3.2
|
||||
- js-yaml@4.3.2
|
||||
trustPolicy: no-downgrade
|
||||
# Skip trust-policy checks for packages published more than 365 days ago.
|
||||
# Several widely-used legacy packages in the current dependency tree have releases that dropped
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"@base-ui/react": "workspace:*",
|
||||
"@base-ui/utils": "workspace:*",
|
||||
"@mui/internal-bundle-size-checker": "1.0.9-canary.83",
|
||||
"radix-ui": "^1.4.3"
|
||||
"radix-ui": "^1.6.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"cross-env": "10.1.0"
|
||||
|
||||
+5
-5
@@ -9,17 +9,17 @@
|
||||
"@base-ui/utils": "workspace:*",
|
||||
"@playwright/test": "1.62.1",
|
||||
"@testing-library/dom": "10.4.1",
|
||||
"@testing-library/jest-dom": "6.9.1",
|
||||
"@testing-library/jest-dom": "7.0.1",
|
||||
"@types/react": "19.2.18",
|
||||
"@types/react-dom": "19.2.4",
|
||||
"@types/react-dom": "19.2.7",
|
||||
"docs": "workspace:^",
|
||||
"es-toolkit": "1.50.0",
|
||||
"es-toolkit": "1.52.0",
|
||||
"is-wsl": "3.1.1",
|
||||
"react": "19.2.8",
|
||||
"react-dom": "19.2.8",
|
||||
"react-router": "7.18.2",
|
||||
"react-router": "8.3.1",
|
||||
"util": "0.12.5",
|
||||
"webpack": "5.109.2",
|
||||
"webpack": "5.110.3",
|
||||
"yargs": "18.1.0"
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,8 @@
|
||||
"devDependencies": {
|
||||
"@mui/internal-benchmark": "0.0.3-canary.7",
|
||||
"@types/react": "19.2.18",
|
||||
"@vitest/browser-playwright": "4.1.10",
|
||||
"vite": "8.2.1",
|
||||
"vitest": "4.1.10"
|
||||
"@vitest/browser-playwright": "4.1.11",
|
||||
"vite": "8.2.2",
|
||||
"vitest": "4.1.11"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user