Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form Components: Accessibility Tree not updating when id changes #2588

Open
nmerget opened this issue Apr 26, 2024 · 2 comments · May be fixed by #2599
Open

Form Components: Accessibility Tree not updating when id changes #2588

nmerget opened this issue Apr 26, 2024 · 2 comments · May be fixed by #2599
Labels
👂accessibility Accessibility issues/improvements 🐛bug Something isn't working

Comments

@nmerget
Copy link
Member

nmerget commented Apr 26, 2024

Currently, we add a default id to our form components like textarea,input, etc.
OnMount we update the id and which is connected with the <label>.

The accessibility tree isn't updating when this id changes. Therefore the label gets duplicated for screen-reader users:
image

A solution could be to move the form-component into the <label> or work with aria-hidden ?

@nmerget nmerget added 🐛bug Something isn't working 👂accessibility Accessibility issues/improvements labels Apr 26, 2024
@mfranzke
Copy link
Member

I don't see a use case for an id that would change after initially mounted. Is this mainly meant for resilience ?

@nmerget
Copy link
Member Author

nmerget commented Apr 26, 2024

Our implementation looks like this:

	onMount(() => {
		state._id = props.id || 'input-' + uuid();
		state._dataListId = props.dataListId || `datalist-${uuid()}`;
	});

	onUpdate(() => {
		if (state._id) {
			state._messageId = state._id + DEFAULT_MESSAGE_ID_SUFFIX;
			state._validMessageId = state._id + DEFAULT_VALID_MESSAGE_ID_SUFFIX;
			state._invalidMessageId =
				state._id + DEFAULT_INVALID_MESSAGE_ID_SUFFIX;
		}
	}, [state._id]);

We need to connect all messages for aria-describedby

@nmerget nmerget linked a pull request Apr 30, 2024 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👂accessibility Accessibility issues/improvements 🐛bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants