Skip to content

Commit

Permalink
fix(ui-time-select): clear input field after setting an empty value
Browse files Browse the repository at this point in the history
  • Loading branch information
ToMESSKa committed Jan 21, 2025
1 parent 6c85b31 commit 7451c89
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/ui-time-select/src/TimeSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -400,14 +400,13 @@ class TimeSelect extends Component<TimeSelectProps, TimeSelectState> {
}
const selectedOption = this.getOption('id', selectedOptionId)
let newInputValue = defaultValue
if (selectedOption) {
// If there is a selected option use its value in the input field.
newInputValue = selectedOption.label
}
// if input was completely cleared, ensure it stays clear
// e.g. defaultValue defined, but no selection yet made
else if (inputValue === '') {
if (inputValue === '') {
newInputValue = ''
} else if (selectedOption) {
// If there is a selected option use its value in the input field.
newInputValue = selectedOption.label
}
this.setState(() => ({
isShowingOptions: false,
Expand Down

0 comments on commit 7451c89

Please sign in to comment.