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

Bug fix matcher not triggering #2560

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mrtnpar
Copy link

@mrtnpar mrtnpar commented Dec 2, 2023

Description

This PR intends to fix issue #2542

Why this issue occurs?

Since form input uses the native change event, programmatically updates doesn't emits.
Also if a validation error has already triggers and input.value gets updated with same value validation disappear, because input event doesn't detect a change hence event change not emits.
Currently this is happening for custom and non-custom matchers, i.e. type="email" inputs.

Before
https://github.com/radix-ui/primitives/assets/74157/d2be0df4-403c-491d-bf66-a1bec00e33d7

After
https://github.com/radix-ui/primitives/assets/74157/968d2091-fdd3-492d-b900-986a55707ae1

Since form input uses the native `change` event, programatically changes
doesn't emits. Also if a validationn error has alredy triggers and inout
gets updated with same value, validation disappear and form can be
submit.

Before this fix is happening on custom matcher, and non-custom matcher.
issue: radix-ui#2542
control.dispatchEvent(new Event('change'));
};
control.addEventListener('blur', handleBlur);
return () => control.removeEventListener('change', handleBlur);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the code, are you sure you want to remove the 'change' event ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants