-
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
Disallow creation of empty links using Link UI directly #35060
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 tasks
getdave
added
the
[Feature] Link Editing
Link components (LinkControl, URLInput) and integrations (RichText link formatting)
label
Sep 22, 2021
Size Change: -1.38 kB (0%) Total Size: 1.06 MB
ℹ️ View Unchanged
|
javierarce
approved these changes
Sep 23, 2021
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.
Nice, this works well.
Previously searches for "initial suggestions" (see docs) were made even if the search string was purely whitespace. By improving the test for initialsuggestions we avoid these unwanted searches.
getdave
force-pushed
the
fix/link-ui-disallow-creation-of-empty-links
branch
from
September 24, 2021 08:42
69eae72
to
be13b69
Compare
adamziel
reviewed
Sep 28, 2021
adamziel
reviewed
Sep 28, 2021
adamziel
reviewed
Sep 28, 2021
adamziel
approved these changes
Sep 28, 2021
ralucaStan
added a commit
to ralucaStan/gutenberg
that referenced
this pull request
Oct 28, 2021
Trimming gets done in the function itself, since PR WordPress#35060.
getdave
added a commit
that referenced
this pull request
Nov 5, 2021
* Fix the update of link and suggestions in LinkControl When switching between two links, the LinkControl component does not unmount. The value prop will change but the component does not react to this change and does not show the updated link & suggestions. * Remove trim from function argument for updateSuggestions. Trimming gets done in the function itself, since PR #35060. * Update packages/block-editor/src/components/url-input/index.js Co-authored-by: Dave Smith <[email protected]> * Take into consideration the case when the value changes with an empty string This was removed by the first commits, but we need to take into consideration that we also want to show the initial suggestions when the new value is empty * Update packages/block-editor/src/components/url-input/index.js Co-authored-by: Dave Smith <[email protected]> Co-authored-by: Dave Smith <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
[Feature] Link Editing
Link components (LinkControl, URLInput) and integrations (RichText link formatting)
[Type] Bug
An existing feature does not function as intended
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
In #17972 (comment) we learnt that you can create empty links using the Link UI. This doesn't seem like something we should allow (I'm open to counter opinions!).
To add an empty link all you need do is add a link to a paragraph of text and then either with/without typing in a few spaces:
This will result in an empty link. There's nothing to stop you submitting it...which seems odd.
This PR works on the premise that "empty" means no value or a value composed purely of whitespace. It employs a basic fix to:
ENTER
to submit when focused in the input and the input is empty.Note this PR does not attempt to fix the situation whereby you can still create an empty link by using the "Code view" of the editor. That is handled in a companion PR.
How has this been tested?
Try out the issue first on
trunk
in order to experience the error.Then retry on this PR's branch.
Enter
or the "Submit" button. See that the link will now not be created.ENTER
or "Submit" again. See the link won't be created.Screenshots
Before
Screen.Capture.on.2021-09-22.at.19-56-12.mov
After
Screen.Capture.on.2021-09-22.at.19-53-39.mov
Types of changes
Checklist:
*.native.js
files for terms that need renaming or removal).