Skip to content

Remove TimePicker state and Moment dependency#25471

Closed
pablinos wants to merge 33 commits intoWordPress:update/post-schedule-switch-calendar-componentfrom
pablinos:remove/timepicker-state
Closed

Remove TimePicker state and Moment dependency#25471
pablinos wants to merge 33 commits intoWordPress:update/post-schedule-switch-calendar-componentfrom
pablinos:remove/timepicker-state

Conversation

@pablinos
Copy link
Copy Markdown
Member

Description

While working on the post schedule feature, @retrofox and I noticed that there are a number of bugs with the implementation of the DateTimePicker. The TimePicker was holding its own local state, and would only update the month when the select component lost focus.

This change updates the TimePicker component to:

  • Not rely on local state
  • Use date-fns rather than Moment
  • Tweak the triggering of the onChange callback.

How has this been tested?

Locally using Storybook

Screenshots

Types of changes

This could be a breaking change, depending on how others are using the TimePicker component.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@pablinos pablinos marked this pull request as draft September 19, 2020 00:58
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm not sure this default is needed, as it's initialised elsewhere, and should probably be handled by default props instead. This is a reminder to me to remove it!

@ZebulanStanphill ZebulanStanphill added the [Type] Bug An existing feature does not function as intended label Sep 19, 2020
@pablinos pablinos force-pushed the remove/timepicker-state branch from 418b6de to 7ef881a Compare September 20, 2020 10:55
@pablinos
Copy link
Copy Markdown
Member Author

I'm getting a problem when this is used with our version of the DatePicker based on React DateTimePicker. It has code to grab focus when the selected date changes. This is happening as I tab out of one of the TimePicker's input fields, but strangely not when I hit enter. This is odd as it causes the same update function to be called.

Comment on lines 6 to 8
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
import startOfMinute from 'date-fns/startOfMinute';
import set from 'date-fns/set';
import format from 'date-fns/format';
import { format, set, startOfMinute } from 'date-fns';

Comment on lines 42 to 43
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
function IntegerValidatedField( { as, value, onUpdate, ...props } ) {
const element = as ?? 'input';
function IntegerValidatedField( { as = 'input', value, onUpdate, ...props } ) {
const element = as;

@retrofox retrofox force-pushed the update/post-schedule-switch-calendar-component branch from 5561271 to 36bf38c Compare September 21, 2020 15:07
@pablinos pablinos force-pushed the remove/timepicker-state branch from 15c5191 to b757a45 Compare September 21, 2020 20:02
@ZebulanStanphill ZebulanStanphill added the [Package] Components /packages/components label Sep 22, 2020
@retrofox retrofox force-pushed the update/post-schedule-switch-calendar-component branch from 3234078 to 58bf061 Compare September 22, 2020 18:34
@stokesman
Copy link
Copy Markdown
Contributor

I'd wager that all the problems this PR intended to address are since resolved and the last push here is going to be three years old soon. We should close this one out, no?

@pablinos
Copy link
Copy Markdown
Member Author

I'd wager that all the problems this PR intended to address are since resolved and the last push here is going to be three years old soon. We should close this one out, no?

Yes we should!

@pablinos pablinos closed this Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Components /packages/components [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants