Skip to content

Fix TextInput being marked dirty from focus#255

Merged
MelissaAutumn merged 2 commits intomainfrom
bugs/254-fix-dirty-textinput
Apr 10, 2026
Merged

Fix TextInput being marked dirty from focus#255
MelissaAutumn merged 2 commits intomainfrom
bugs/254-fix-dirty-textinput

Conversation

@MelissaAutumn
Copy link
Copy Markdown
Member

Fixes #254
Fixes #99

We should only be marking a text input as dirty if we change something in it, and not when we simply focus and blur away. This fixes my main annoyance with our textinput 😄

Also I added a story for #99 and confirmed readonly works as intended.

@MelissaAutumn MelissaAutumn self-assigned this Apr 10, 2026
Copy link
Copy Markdown
Collaborator

@devmount devmount left a comment

Choose a reason for hiding this comment

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

Nice, thanks so much for this fix! I can take a look at the other input components for #207


const onBlur = (evt) => {
if (evt.target.checkValidity()) {
if (isDirty.value && evt.target.checkValidity()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If the text input is marked as required, should the blur on an empty text input trigger the checkValidity? That would mean that the user "passed through" without filling the input itself.

Ref https://thunderbird.github.io/services-ui/?path=/story/components-textinput--required

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thankfully that is covered automatically for us!
https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/required#constraint_validation

We already show "this field is required" we don't need to warn them about how the field is empty until we check for validation OR unless they dirty the input.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah I thought that we wanted to warn them with our own error design instead of mixing in the built-in styles. All good then!

@MelissaAutumn
Copy link
Copy Markdown
Member Author

Nice, thanks so much for this fix! I can take a look at the other input components for #207

Oh that's where the ticket was. I thought we had one but couldn't find it and this issue was driving me crazy. Please do though 😄

@MelissaAutumn MelissaAutumn merged commit e956c26 into main Apr 10, 2026
3 checks passed
@MelissaAutumn MelissaAutumn deleted the bugs/254-fix-dirty-textinput branch April 10, 2026 17:38
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.

TextInput should not immediately mark input as dirty TextInput should be able to receive / forward the readonly attribute

3 participants