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 floating date status inferred for posts where the status has been edited #28127

Merged
merged 2 commits into from
Jan 13, 2021
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
1 change: 0 additions & 1 deletion packages/editor/src/components/post-schedule/label.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { withSelect } from '@wordpress/data';

export function PostScheduleLabel( { date, isFloating } ) {
const settings = __experimentalGetSettings();

return date && ! isFloating
? format(
`${ settings.formats.date } ${ settings.formats.time }`,
Expand Down
7 changes: 6 additions & 1 deletion packages/editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,12 @@ export function isEditedPostBeingScheduled( state ) {
export function isEditedPostDateFloating( state ) {
const date = getEditedPostAttribute( state, 'date' );
const modified = getEditedPostAttribute( state, 'modified' );
const status = getEditedPostAttribute( state, 'status' );

// This should be the status of the persisted post
// It shouldn't use the "edited" status otherwise it breaks the
// infered post data floating status
// See https://github.com/WordPress/gutenberg/issues/28083
const status = getCurrentPost( state ).status;
if (
status === 'draft' ||
status === 'auto-draft' ||
Expand Down
20 changes: 20 additions & 0 deletions packages/editor/src/store/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2010,6 +2010,26 @@ describe( 'selectors', () => {

expect( isEditedPostDateFloating( state ) ).toBe( true );
} );

it( 'should return false for private posts even if the edited status is "draft"', () => {
const state = {
currentPost: {
date: '2018-09-27T01:23:45.678Z',
modified: '2018-09-27T01:23:45.678Z',
status: 'private',
},
editor: {
present: {
edits: {
status: 'draft',
},
},
},
initialEdits: {},
};

expect( isEditedPostDateFloating( state ) ).toBe( false );
} );
} );

describe( 'isSavingPost', () => {
Expand Down