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

feat(text-field): reset value on type change #6834

Merged
merged 5 commits into from
Jun 14, 2024

Conversation

43081j
Copy link
Contributor

@43081j 43081j commented Sep 18, 2023

This changes fast-text-field to reset its value any time type changes.

The reason for this is that switching between two incompatible input types may reset the inner control's value, which won't otherwise be reflected to the outer element.

For example, using type="text" and typing a value into the input, then changing to type="number". This should reset the value, since the inner control will have already done so.

🎫 Issues

Fixes #6827

👩‍💻 Reviewer Notes

In material, this is solved by resetting the value any time the component's properties change at all. Maybe we should do the same here? I just wasn't sure if there's a lifecycle callback in FAST for when any properties change.

I'm also not too sure the test I've added is consistent with how you usually test this stuff. I didn't see any other tests testing the members of the element itself, only via attributes.

If you want to solve this another way, let me know and I'm happy to update.

📑 Test Plan

Added a new test for changing type after input has occurred.

✅ Checklist

General

  • I have included a change request file using $ yarn change
  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

Component-specific

Copy link
Collaborator

@scomea scomea left a comment

Choose a reason for hiding this comment

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

Seems reasonable, change file needs to be corrected tho.

@43081j
Copy link
Contributor Author

43081j commented Jan 23, 2024

sorry only just got around to this

have rebased on master and updated the change file

This changes `fast-text-field` to reset its value any time `type`
changes.

The reason for this is that switching between two incompatible input
types may reset the inner control's value, which won't otherwise be
reflected to the outer element.

For example, using `type="text"` and typing a value into the input, then
changing to `type="number". This should reset the value, since the inner
control will have already done so.
@43081j
Copy link
Contributor Author

43081j commented Feb 26, 2024

have rebased onto latest master

any chance anyone can take a look at merging this some day? 👀

@janechu janechu merged commit d1685de into microsoft:master Jun 14, 2024
5 checks passed
@43081j 43081j deleted the input-type-values branch June 15, 2024 10:36
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.

fix: Value of text-field is not updated when the text-field type changes
4 participants