-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 toggle new tab does not persist changes to text input in Link Control #50401
Conversation
Update: fixed the issue visible in the Video timestamp: 1:16 in here: de648d1Here's a video demonstration of the fix. link.control.fix.demonstration.mp4 |
Thank you @hz-tyfoon @getdave Dave what are your thoughts here? |
Silly me, found an issue watching my own video 😅😅 where the Amazon link didn't update to "open in new tab" after submission (Video timestamp: 1:16). Identified the issue in the codebase and also fixed it in: de648d1 |
the issue shown in the video is fixed in last 2 commits (9409630491 & 328d933c97).issue_with_button_block.mp4 |
Thank you for the PR. It is on my list to review. |
@hz-tyfoon I think the best bet is you rebasing the fix with upstream |
Thanks @getdave for replying. 😊 Just noting few things: I believe My repo is public and U can access it. But no worries, I'll try to resolve the conflicts later or create a new PR later on the But, when I read this comment & the video there it looked to me that current state of Looks to me if I proceed from the 1 thing poped into my head & that is to try to get some eyes on this and get peoples feedback on the Any guidance would be appreciated as to how I should proceed in the light of this |
Ah yes I'd forgotten that thanks for reminding me. So for the 6.3 cycle we're anticipating some changes to the So I think we'll need to have x2 fixes. One to be backported to |
Thanks for replying so quick 🚀. Meanwhile, It'd be great if we get some more feedback, review or comment from other people too. |
I think the diff is too messed up for that right now. I was planning to solve this in 6.3 by requiring that all changes to the link But a fix for 6.2 would need to be more along the lines of what you propose here. |
Ok then. |
Hi @hz-tyfoon let's try to fix this PR because no one can see the code changes to review.
Then this PR will show the diff so we can review the code and move on. Let me know how it went :) |
Thanks @draganescu 😊 here's the old 4 commits(if needed) before the force push: 1st. f545717 2nd. de648d16 3rd. 9409630 4th. 328d933c978b3dffd07c82157d6f589d0157d263 [note: we had a brief chat about it on today's meeting] |
const __newOnChangeForLinkControl = ( callback1, callback2, value ) => { | ||
callback1( value ); | ||
callback2( value ); | ||
}; |
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.
If we go with this route we can curry the function to pre-apply the handlers. That way you can just pass the new value
to the curried function.
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.
refactored the __newOnChangeForLinkControl
to call it just with the values in 91306d3.
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.
Thank you for working on this.
What I'm seeing is that we're going to try and store the unsubmitted changes in internal component state.
The key is that value
(the controlled prop) should be the source of truth and that any internal state should only exist until the point of submission. If it's not submitted then the internal state should be reset to whatever value
is passed in.
I'm going to dive into this in more detail here before I make further suggestions.
Thanks @getdave 😊 for the review. I think U got the right idea about what I tried to do here. |
…Control' component (renamed as 'newOnChangeForLinkControl') to call it just with the 'value'
Updated the PR to call again noting that: at this point this PR's work changing the UI of |
Updated version of the PR is this 👉 #50602. Probaly gonna close this PR soon, but keeping it open for now to get some feedback as to if this one is a a better candidate just for a cherry pick to wp/6.2 minor release. The mentioned updated PR is created as this one doesn't maintain the current state/UI/UX of the link-control component. See the conversations above & the videos shown there for more clarity |
@hz-tyfoon I don't understand what is the difference between the two PRs :) |
@draganescu if you apply this PR's patch & then try it U'll find the UI has been changed & that's because my initial PR's base was taken from Now, But, if we decide that we don't want to cherry pick this fixs into I tried to explain my thinking & hope this wasn't confusing. 😊 |
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.
I believe upcoming changes to the Nav block are going to necessitate changes to the Link UI. As a result let's hold off on merging this PR until we're sure on the desired UX for the control.
I think the idea is along the right lines but let's take our time to get this right. I'll circle back here asap.
Thank you again for your patience.
I believe this is now resolved by #50945. @hz-tyfoon Apologies that this got superseded. If you're interested there are lots of open tasks on the tracking Issue for the refresh project. |
Updated version of the PR is this 👉 #50602. Probaly gonna close this PR soon, but keeping it open for now to get some feedback as to if this one is a a better candidate just for a cherry pick to
wp/6.2 minor release
.The mentioned updated PR is created as this one doesn't maintain the current state/UI/UX of the
link-control
component. See the conversations & the videos shown there for more clarityThis PR fixes issues: #45741 & #43144
Here's what I did in my code to fix this issue👇:
** step 1: took a new state 'newValue' and used the 'recieved 'value' prop' as default.
** step 2: replaced the 'value' with 'newValue' state everywhere. It's help us to change the 'value' without causing any mutation using 'setNewValue' when we need it
** step 3: passed 'setNewValue' function to 'LinkControlSettingsDrawer' component to be able to change the value from inside that component
** step 4: in 'settings-drawer.js' file used the passed 'setNewValue' function to update 'just the settings' and keeping the other values to make sure no mutation happen to the original 'value' prop
** step 5: removed 'onChange' entirely from 'LinkControlSettingsDrawer' as 'this onchange call is the culprit' that causes the link modal to close. also removed passing the 'onChange' as a prop to 'LinkControlSettingsDrawer' component in the 'index.js' file as it's no longer used