-
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
link-control: implement onEdit mode #18225
Conversation
Related comment #18062 (comment) |
Adding another issue reference #18135 |
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.
Looks good but we're missing tests for this feature.
I'll write one. ✅ I've added one.
@retrofox Actually just realised you need to update the |
// Populate input searcher whether | ||
// the current link has a title. | ||
if ( currentLink && currentLink.title ) { | ||
setInputValue( currentLink.title ); | ||
} |
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 need this to be an "initializer" for the input value, couldn't we instead provide this as the initial value for the input state?
In other words, instead of:
const [ inputValue, setInputValue ] = useState( '' ); |
Do:
const [ inputValue, setInputValue ] = useState( value.title );
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.
See: #19737
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.
It makes totally sense to me, Andrew. I don't exactly the reason why we added this initializer, especially because this component has been significantly refactored lately.
Going to help to review at your PR.
Description
It adds the idea of
edit
mode explicitly for the<LinkControl />
component.Currently, this component changes its edit mode looking at the changes of
currentLink
property. This approach is used when it selects a new link from the link suggestions, and also when it clicks in the Change button.The tricky part comes when:
currentLink.title
valueWe need to change the
currentLink
to trigger the edit mode, but at the same time, we want to keep thecurrentLink
value in order to populate the searcher input with its title.This PR set the edit mode explicitly and internally, populating the title if it's defined.
How has this been tested?
It has been tested in this PR: #18062.
Change
buttonThe searcher input should be populated with the current link title.
Screenshots
Checklist: