Skip to content

Fix: "View as" link is not updated after the post is updated and the permalink is changed#11262

Merged
jorgefilipecosta merged 1 commit into
masterfrom
fix/view-as-link-is-not-updated-after-post-is-saved-and-the-permalink-changes
Nov 7, 2018
Merged

Fix: "View as" link is not updated after the post is updated and the permalink is changed#11262
jorgefilipecosta merged 1 commit into
masterfrom
fix/view-as-link-is-not-updated-after-post-is-saved-and-the-permalink-changes

Conversation

@jorgefilipecosta
Copy link
Copy Markdown
Member

Fixes: #7275

The editor contains a "View as" pointing to the post permalink on the top bar.
This link comes from the page rendered on the server. When the post is updated with a permalink change the page is not rendered again so the "View as" link continued to be the same.
This PR adds an effect to update the dom of the "View as" link to contain the new permalink when the post is saved with success and the permalink was changed.

How has this been tested?

Create a new post, and publish it.
Reload the editor and verify we have a "View as" link in the top bar.
Change the post permalink and press update, verify that when the post is saved with success the View as link points to the new permalink.

@jorgefilipecosta jorgefilipecosta added the [Type] Bug An existing feature does not function as intended label Oct 30, 2018
@jorgefilipecosta jorgefilipecosta added this to the WordPress 5.0 milestone Oct 30, 2018
@gziolo gziolo modified the milestones: WordPress 5.0, 4.3 Nov 5, 2018
REQUEST_POST_UPDATE: ( action, store ) => {
requestPostUpdate( action, store );
},
REQUEST_POST_UPDATE_SUCCESS: requestPostUpdateSuccess,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is the old effect requestPostUpdateSuccess not necessary anymore?

updateViewAsPermalink seems undefined right?

return;
}
nodeToUpdate.setAttribute( 'href', newPermalink );
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we move this effect to the edit-post module instead? Ideally, the editor package has no knowledge about any WP context.

@jorgefilipecosta jorgefilipecosta force-pushed the fix/view-as-link-is-not-updated-after-post-is-saved-and-the-permalink-changes branch 2 times, most recently from f717c79 to 63d06fa Compare November 6, 2018 19:55
@jorgefilipecosta
Copy link
Copy Markdown
Member Author

Hi @youknowriad thank you for your review, this PR is now using a different approach attending to your feedback.

@designsimply designsimply added the [Feature] Permalink The permalink of a post or page and the experience of setting or editing it label Nov 7, 2018
Copy link
Copy Markdown
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@jorgefilipecosta jorgefilipecosta force-pushed the fix/view-as-link-is-not-updated-after-post-is-saved-and-the-permalink-changes branch from 63d06fa to 9f99d1a Compare November 7, 2018 09:26
@jorgefilipecosta jorgefilipecosta merged commit f23242b into master Nov 7, 2018
@jorgefilipecosta jorgefilipecosta deleted the fix/view-as-link-is-not-updated-after-post-is-saved-and-the-permalink-changes branch November 7, 2018 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Permalink The permalink of a post or page and the experience of setting or editing it [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