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

Keep post publishing popover open when a date is clicked #29738

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/components/src/date-time/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,10 @@ This function will be called on each day, every time user browses into a differe

- Type: `Function`
- Required: No

### keepOpen
retrofox marked this conversation as resolved.
Show resolved Hide resolved

Whether focus should stay on the `DateTimePicker` after clicking on a date in the calendar.

- Type: `bool`
- Required: No
7 changes: 6 additions & 1 deletion packages/components/src/date-time/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class DatePicker extends Component {
}

onChangeMoment( newDate ) {
const { currentDate, onChange } = this.props;
const { currentDate, onChange, keepOpen } = this.props;

// If currentDate is null, use now as momentTime to designate hours, minutes, seconds.
const momentDate = currentDate ? moment( currentDate ) : moment();
Expand All @@ -70,6 +70,11 @@ class DatePicker extends Component {
};

onChange( newDate.set( momentTime ).format( TIMEZONELESS_FORMAT ) );

// Keep focus on the date picker popover.
if ( keepOpen ) {
this.keepFocusInside();
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/date-time/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function DateTimePicker(
onMonthPreviewed,
onChange,
events,
keepOpen,
retrofox marked this conversation as resolved.
Show resolved Hide resolved
},
ref
) {
Expand All @@ -54,6 +55,7 @@ function DateTimePicker(
isInvalidDate={ isInvalidDate }
onMonthPreviewed={ onMonthPreviewed }
events={ events }
keepOpen={ keepOpen }
/>
</>
) }
Expand Down
1 change: 1 addition & 0 deletions packages/editor/src/components/post-schedule/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export function PostSchedule( { date, onUpdateDate } ) {
currentDate={ date }
onChange={ onChange }
is12Hour={ is12HourTime }
keepOpen={ true }
/>
);
}
Expand Down