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

[datetime] fix(TimePicker): reset input fields when value={null} #4845

Merged
merged 6 commits into from
Aug 16, 2021

Conversation

dummycode
Copy link
Contributor

@dummycode dummycode commented Aug 6, 2021

Fixes #4775

Checklist

  • Includes tests
  • Update documentation

Changes proposed in this pull request:

Updating TimePickers value to null should behave the same way as when it was constructed: get min time or default value.

Reviewers should focus on:

Whether this breaks any existing functionality.

Screenshot

output

@palantirtech
Copy link
Member

Thanks for your interest in palantir/blueprint, @dummycode! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request.

Copy link
Contributor

@adidahiya adidahiya left a comment

Choose a reason for hiding this comment

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

nice, simple fix. I'll make sure to note this change in behavior in the release notes.

@@ -100,7 +100,11 @@ export class DateTimePicker extends AbstractPureComponent2<IDateTimePickerProps,
onChange={this.handleDateChange}
value={value}
/>
<TimePicker {...this.props.timePickerProps} onChange={this.handleTimeChange} value={value} />
<TimePicker
Copy link
Contributor

Choose a reason for hiding this comment

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

this component is deprecated, please revert these changes. users should be using <DatePicker> instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without this change, the test changing the time before selecting a date works as expected fails because clearing the date also clears the time because the TimePicker component now responds to being passed null, whereas before it was a no-op. Should I still revert this change?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, fair enough, we can include this change in the PR.

@@ -222,9 +215,12 @@ export class TimePicker extends React.Component<TimePickerProps, ITimePickerStat
const didMaxTimeChange = prevProps.maxTime !== this.props.maxTime;
const didBoundsChange = didMinTimeChange || didMaxTimeChange;
const didPropValueChange = prevProps.value !== this.props.value;
const shouldStateUpdate = didMinTimeChange || didMaxTimeChange || didBoundsChange || didPropValueChange;
Copy link
Contributor

Choose a reason for hiding this comment

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

good catch... this expression was redundant

@adidahiya adidahiya changed the title Time picker resets value when passed null [datetime] fix(TimePicker): reset input fields when value is null Aug 13, 2021
This reverts commit 56b374c.
Copy link
Contributor

@adidahiya adidahiya left a comment

Choose a reason for hiding this comment

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

looks good in docs preview

@@ -100,7 +100,11 @@ export class DateTimePicker extends AbstractPureComponent2<IDateTimePickerProps,
onChange={this.handleDateChange}
value={value}
/>
<TimePicker {...this.props.timePickerProps} onChange={this.handleTimeChange} value={value} />
<TimePicker
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, fair enough, we can include this change in the PR.

@adidahiya adidahiya changed the title [datetime] fix(TimePicker): reset input fields when value is null [datetime] fix(TimePicker): reset input fields when value={null} Aug 16, 2021
@adidahiya adidahiya merged commit 41b5e05 into palantir:develop Aug 16, 2021
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.

Pressing "Clear" on DatePicker with TimePicker doesn't clear time inputs
3 participants