-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 Link Control 'Open in new tab' option not saving properly on committing link in buttons block #42073
Conversation
@hz-tyfoon Thank you for the PR. It's much appreciated 👏 I tested this with the standard link in the Post Editor and I was unable to reproduce. I could however, reproduce with the buttons block. This is using latest Gutenberg Screen.Capture.on.2022-06-30.at.15-45-31.movI believe this is likely due to the fact that the At first glance, your fix seems good, but I'm going to dig a little deeper and see if there's fundamental problem with the handler in richtext vs the button block. Also please could you resolve the unit tests? 🙇 |
The issue is that LinkControl will call So when the user clicks "Open in new tab" gutenberg/packages/block-library/src/button/edit.js Lines 229 to 230 in b0244c2
However, when the user clicks submit to "commit" the link then due to the problem that @hz-tyfoon identified the original value of On balance I think we should update LinkControl to provide the stored value on commit as per this PR. We should update the tests to assert on the full value being provided. Please could you add |
Hey @getdave. 🙂
⬆️ I was talking about this issue #42080 with the standard link in the Post Editor. I'm not sure why the unit tests always so stubborn. In my first contribution few days earlier it failed 5-6 times and finally it passed after re-running the test again. |
Agreed. 👍 |
Looks like this PR also fixing this issue #40243 as well. |
@hz-tyfoon Thanks for working on this. There's a unit test for link editing that's failing as a result of these changes and will need to be updated - https://github.com/WordPress/gutenberg/runs/7173641105?check_suite_focus=true. There's a comment on the other PR that mentions the same issue, and has some details for solving it - #40244 (comment). |
Sorry for late reply, I somehow didn't notice your comment earlier. @talldan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - tests now streamlined and the fix seems good. The controlled component should always pass the entire value
when it calls the onChange
handler. This PR addresses that so I think it's good.
Shouldn't (issue: #42032) also be closed, as this PR was originally created to solve that? 🤔 |
This PR fixes #40243
[note: The mentioned issue was not only in buttons block but in the 'link-control' component]