-
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
Make Link UI inactive if selection extends beyond format bounds or encounters new link #35946
Make Link UI inactive if selection extends beyond format bounds or encounters new link #35946
Conversation
Size Change: +138 B (0%) Total Size: 1.07 MB
ℹ️ View Unchanged
|
} ); | ||
|
||
if ( | ||
! linkFormatAtStart || |
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 no format here then we've exceeded the leftmost side of the link boundary.
|
||
if ( | ||
! linkFormatAtStart || | ||
! linkFormatAtEnd || |
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 no format here then we've exceeded the rightmost side of the link boundary.
if ( | ||
! linkFormatAtStart || | ||
! linkFormatAtEnd || | ||
linkFormatAtStart !== linkFormatAtEnd |
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 they do not display referential equality then we're dealing with two separate links.
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.
Does this mean that if the links are the same the UI shows?
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.
Screen.Capture.on.2021-10-26.at.14-09-46.mov
Nope. Not in my testing. This is because the two link format objects are not referentially equal (i.e. they are not the same format object).
Note in the video above the two items I'm console.log
ing are linkFormatAtStart
and linkFormatAtEnd
// the bounds of the link format. | ||
// Also if the format objects don't match then we're dealing with two separate | ||
// links so we should not allow the link to be modified over the top. | ||
if ( name === 'core/link' && ! isCollapsed( 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.
No need to handle collapsed selections because for these start
and end
will be identical and thus there is no "selection".
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.
Could we remove the hard coding of a format name here?
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.
Sure. Are you suggesting to replace with a reference instead? Or were you suggesting something else?
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.
Why has this been merged while it's hardcoding link logic in the rich text component?
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.
Apologies. That must have been an oversight despite your comment here. Both Andrei and I must have missed it in the Github UI even though I responded 🤦
My question still stands though. How can we work around this?
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.
Not sure I understand the question 😅
In any case, I've made a PR here: #48789
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.
Not sure I understand the question 😅
Neither do I nearly a year down the line 😄 I think it was "do you have any thoughts on how we could proceed"...and I'm not surprised by the fact that you did (do!).
Thank you for following up here.
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.
This fix worked fine for me. The LinkControl UI closed allowing me to create a new link from a highlight that started on a link and contained several other ones.
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.
Codewise this looks straightforward.
Co-authored-by: andrei draganescu <me@andreidraganescu.info>
Waiting on #35961 so we can skip the test. |
Description
This PR seeks to solve the problem highlighted by @ellatrix in #33849 (comment) (and which is currently blocking the merge of that important PR).
Currently if you make a link and then make a selection that begins inside the link and extends either:
...then the Link UI will remain active even though you're outside the original format you selected.
This allows you to get into undesirable states such as:
This PR resolves this. The UX is now that the Link UI will disappear (become inactive) if:
Originally part of #35882. Now broken out into a seperate PR.
How has this been tested?
Manual testing
Bottom line: if the selection goes:
...then the Link UI should disappear.
Screenshots
Before
Screen.Capture.on.2021-10-26.at.09-41-25.mov
After
Screen.Capture.on.2021-10-26.at.09-44-26.mov
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist:
*.native.js
files for terms that need renaming or removal).