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

Block Editor: Link Control: Initialize inputValue state from value #19737

Merged
merged 2 commits into from
Jan 20, 2020

Conversation

aduth
Copy link
Member

@aduth aduth commented Jan 17, 2020

Previously: #18225 (comment), https://github.com/WordPress/gutenberg/pull/19396/files#r368127421

This pull request seeks to change the behavior of the LinkControl component to initialize its inputValue state as being derived from the value prop.

This...

  • ...Avoids the need for a setMode utility function altogether
  • ...Ensures better syncing of the relationship between inputValue state and the value prop
  • ...Resolves inconsistency where not all mode changing would occur through setMode [1] [2]

There is also one change in behavior, inherited from #19462:

  • The edit field is prepopulated with the link URL, rather than with the link title (see discussion).

Testing Instructions:

Ensure unit tests pass:

npm run test-unit

Verify there are no regressions in the behavior of link control.

Notably:

  • Adding a new link should show an empty link field
  • Editing an existing link should prepopulate the link field with its URL
  • Editing and then re-editing while the link dialog is still shown should still reflect the updated value

@aduth aduth added the [Package] Block editor /packages/block-editor label Jan 17, 2020
@aduth aduth requested review from retrofox and youknowriad January 17, 2020 21:35
Copy link
Contributor

@retrofox retrofox left a comment

Choose a reason for hiding this comment

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

Tested an LGTM

  • Adding a new link should show an empty link field
  • Editing an existing link should prepopulate the link field with its URL
  • Editing and then re-editing while the link dialog is still shown should still reflect the updated value

Simpler and clearer. 🙏 .

@aduth aduth merged commit 6d396c0 into master Jan 20, 2020
@aduth aduth deleted the update/link-control-mode-boolean branch January 20, 2020 15:45
@epiqueras epiqueras added this to the Gutenberg 7.4 milestone Feb 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Block editor /packages/block-editor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants