-
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
Trim input value in navigation search input field #19832
Conversation
8ddd6d1
to
a51dfaf
Compare
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 the PR. A nice fix!
It should be ok to remove whitespace from start/end of string. Would you consider adding a unit test in LinkControl
to cover this?
a51dfaf
to
cd5e62d
Compare
|
packages/block-editor/src/components/link-control/test/index.js
Outdated
Show resolved
Hide resolved
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 so much for submitting this. I'd love to see this get merged.
Currently, however, the implementation doesn't correctly ensure the handler which fetches search results over XHR has its search term trimmed. Moreover, the tests give you a false positive. You probably know this already but I felt it was worth pointing out.
I've left a comment with a suggestion on amending both tests and implementation detail to get this working for you.
I'd recommend:
- Rebasing against upstream
master
to bring in the latest changes. - Amending the tests as I suggest (assuming you agree).
- Checking tests correctly confirm the implementation fails (ie: tests fail).
- Amending the implementation.
- Checking tests now pass.
I hope this helps.
cd5e62d
to
43a52f3
Compare
@getdave thanks for the amazing review. The goal of submitting PR is to help you save time and do other more valuable things, but I failed to do that. It's a bit embarrassing. |
ddd3775
to
e318a99
Compare
Fixed merge conflict. |
Looking better. I'm afraid I merged a rather large commit yesterday on |
Conflicts are resolved in my local branch. I'm waiting for your opinion about adding |
e318a99
to
a50d00d
Compare
a50d00d
to
afb057c
Compare
|
afb057c
to
d895cab
Compare
Thanks for your work on this @sainthkh 👍 |
@@ -231,7 +231,7 @@ class URLInput extends Component { | |||
! ( suggestions && suggestions.length ) | |||
) { | |||
// Ensure the suggestions are updated with the current input value | |||
this.updateSuggestions( value ); | |||
this.updateSuggestions( value.trim() ); |
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 the updateSuggestions()
func is expected to always be called with trimmed value
, it's probably better to do the trimming inside that very function. Not a blocker though, just a suggestion - feel free to 🚢 this one. Nice work!
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.
IMHO, it's only duplicated once now. When we need trimming
once more, it's strikeout and let's refactor.
I cannot think of a case that doesn't need trimming. But we don't know the future.
@sainthkh 👋 Are you still intending to merge this? |
@getdave Yes. Or is there any problem? |
Description
Trim input values in navigation search input field.
How has this been tested?
Added related e2e code.
Screenshots
Before:
After:
NOTE: It doesn't show url item at the bottom because
page
is not a valid url.Types of changes
Bug fix
Checklist:
I'm sorry @WunderBart. I realized that I intercepted your issue after finished implementing it.