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 for bug with toggling opensInNewWindow state #17794

Merged

Conversation

glendaviesnz
Copy link
Contributor

Description

Currently the opensInNewWindow state is not toggled in InlineLinkUI if both the activeAttributes.url and activeAttributes.target props both change - in this case only the url change is reflected in the component state due to getDerivedStateFromProps returning before the opensInNewWindow check is hit

How has this been tested?

Tested manually as follows:

  • Apply this patch to your local gutenberg dev env
  • From a post/page editor, create a paragraph block
  • Add a link
  • Set the link to open in a new tab
  • Click anywhere else
  • Click the link -> settings , the “open in a new tab” should still be toggled on
  • Save the page/post and reload the editor
  • Click the link -> settings , the “open in a new tab” should still be toggled on
  • Repeat the above steps with a toggled off state and ensure it also persists correctly

Also added a unit test to check that state.opensInNewWindow is set when props.activeAttributes.target _blank passed in.

Types of changes

Fixes #17770

Checklist:

  • [ x ] My code is tested.
  • [ x ] My code follows the WordPress code style.
  • [ NA ] My code follows the accessibility standards.

Copy link
Member

@ellatrix ellatrix 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, thanks!

@ellatrix ellatrix merged commit 12425d2 into WordPress:master Oct 7, 2019
@glendaviesnz glendaviesnz deleted the fix/17770-new-tab-toggle-bug branch October 7, 2019 21:01
@youknowriad youknowriad added this to the Gutenberg 6.7 milestone Oct 14, 2019
gziolo pushed a commit that referenced this pull request Oct 15, 2019
* Update getDerivedStateFromProps to pass back all state property changes

* Add test to check that state.opensInNewWindow is set correctly on prop change

* Rename test file
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.

"Open New Tab" toggle on links not getting saved
3 participants