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

Fix TimeSelect showing the wrong value when defaultValue is set and entering a wrong value after a good one #1871

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

Conversation

matyasf
Copy link
Collaborator

@matyasf matyasf commented Feb 13, 2025

TimeSelect was resetting to its defaultValue after a valid value was set if entering an invalid value. This commit fixes it by not losing the selected option ID when the input changes

Testing the fix:

Enter the following code:

<TimeSelect
        renderLabel="Choose a time"
        placeholder="e.g., 4:00:00 PM"
        defaultValue="2020-05-18T22:00:00"
        step={15}
        onChange={(e, { value }) => console.log(value)}
        format="LTS"
      />
  1. select a different time than the defaultValue
  2. click into the input field, delete the value inside until there are multiple options shown and click outside/tab away. It should display the value you selected previously. There should be no change event emitted

Fixes INSTUI-4451

…ultValue is set and enteting a wrong value after a good one

TimeSelect was resetting to its defaultValue after a valid value was set if entering an invalid
value. This commit fixes it by not losing the selected option ID when the input changes

INSTUI-4451
@matyasf matyasf requested review from HerrTopi and ToMESSKa February 13, 2025 19:56
@matyasf matyasf self-assigned this Feb 13, 2025
@matyasf matyasf changed the title fix(ui-time-select): fix TimeSelect showing the wrong value when defaultValue is set and entering a wrong value after a good one Fix TimeSelect showing the wrong value when defaultValue is set and entering a wrong value after a good one Feb 13, 2025
Copy link

PR Preview Action v1.6.0

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

Built to branch gh-pages at 2025-02-13 20:01 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

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