[@mantine/core] Input: Add keepErrorMounted prop for persistent error element (aria-live)#8953
Open
phamvutinh wants to merge 1 commit into
Open
[@mantine/core] Input: Add keepErrorMounted prop for persistent error element (aria-live)#8953phamvutinh wants to merge 1 commit into
phamvutinh wants to merge 1 commit into
Conversation
…t mounted for aria-live announcements Closes mantinedev#8932 By default Input.Wrapper unmounts the error element when `error` is not set, which prevents using it as a persistent aria-live region for validation announcements. The new `keepErrorMounted` prop keeps the error node mounted (rendering empty content when there is no error) so its text can be updated in place. Available on all inputs that use Input.Wrapper (Select, TextInput, etc.). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #8932
Problem
Input.Wrapper(and therefore all inputs built on it —Select,TextInput,Textarea, etc.) unmounts the error element entirely when theerrorprop is falsy. This makes it impossible to use Mantine's built-in error node as a reliablearia-liveregion for field-level validation: each time an error appears a brand-new node is mounted instead of an existing one having its text updated, so screen reader announcements become inconsistent. Consumers currently have to render a second custom error element just to make validation accessible.Solution
Add an opt-in
keepErrorMountedprop (defaultfalse, fully backwards compatible). When set, the error element stays mounted even when there is no error, rendering empty content. Its text is then updated in place when an error appears/disappears, giving consumers a stable live-region host:Changes
Input.Wrapper: newkeepErrorMountedprop on__InputWrapperProps; error node renders whenhasError || keepErrorMounted, with empty content when there is no error.aria-describedbyreferences the error id whenever the node is mounted.use-input-props: routekeepErrorMountedto the wrapper so all inputs (Select,TextInput, …) inherit it.get-input-offsets: reserve the error slot spacing whenkeepErrorMountedso layout doesn't shift as the error toggles.input.mdx.InputWrapperandget-input-offsets.Open question for maintainer
I went with an opt-in prop (no behavior change, no layout regression).
aria-liveis left to the consumer viaerrorPropsrather than applied automatically — happy to adjust the approach (e.g. a documented pattern only, or autoaria-live) based on your preference.Checks
npm run typecheck,npx oxlint,npm run build, andnpm run jestfor Input/Select all pass.🤖 Generated with Claude Code