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

INSTUI-4429 fix(ui-time-select): clear input field after setting an empty value #1848

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ToMESSKa
Copy link
Contributor

@ToMESSKa ToMESSKa commented Jan 21, 2025

ISSUE:
In the TimeSelect component, after explicitly setting a value, it cannot be cleared from the input field. When the value is deleted form the input filed and the input field loses focus, the last selected option is reapplied.
Also the onChange does not trigger when input field is cleared.

TEST PLAN:

  • go to the "Controlled" TimeSelect example
  • select a different value than the current one
  • click the input field, delete its current value, and click elsewhere to ensure the input field loses focus
  • the input field now should be cleared and have no option selected apart form the placeholder
  • onChange should be triggered when input is cleared and loses focus
  • test of all the other examples in TimeSelect work as expected
  • review the new test
  • possible a11y issues should be discussed (eg. with only keyboards, the input field cannot be cleared)

Copy link

github-actions bot commented Jan 21, 2025

PR Preview Action v1.6.0

🚀 View preview at
https://instructure.github.io/instructure-ui/pr-preview/pr-1848/

Built to branch gh-pages at 2025-01-23 09:58 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@ToMESSKa ToMESSKa self-assigned this Jan 22, 2025
@ToMESSKa ToMESSKa force-pushed the INSTUI-4429_time_select_unable_to_clear_field_after_setting_a_value branch from 7451c89 to c4c66a9 Compare January 23, 2025 09:53
@ToMESSKa ToMESSKa marked this pull request as ready for review January 23, 2025 10:00
@ToMESSKa ToMESSKa requested a review from matyasf January 23, 2025 10:00
@matyasf matyasf changed the title fix(ui-time-select): clear input field after setting an empty value INSTUI-4429 fix(ui-time-select): clear input field after setting an empty value Jan 24, 2025
Copy link
Collaborator

@matyasf matyasf left a comment

Choose a reason for hiding this comment

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

Nice work!
I think that this new behaviour is much more logical, than the old one. (and the old one was even buggy in the uncontrolled behaviour because you could clear the field when the value was not cleared.)

But I'm afraid that introducing this as a fix could break our user's code, since until now it was impossible for the component to return '' as value, it always returned a valid date.
So can you please put this behind a new prop, say allowClearingSelection (it should default to false) to make sure we dont break code?
Also we could make this new behaviour the default one in the next major version, so please add this to our v11-upgrade-guide.md.

PS I could clear the input with just keyboard, what is the a11y concern here?

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