Skip to content
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

Block disapear when clicking on a link (anchor, <a>) with no href #17657

Closed
nicpelletier opened this issue Sep 30, 2019 · 1 comment · Fixed by #17928
Closed

Block disapear when clicking on a link (anchor, <a>) with no href #17657

nicpelletier opened this issue Sep 30, 2019 · 1 comment · Fixed by #17928
Labels
[Block] Paragraph Affects the Paragraph Block Needs Testing Needs further testing to be confirmed. [Type] Bug An existing feature does not function as intended

Comments

@nicpelletier
Copy link

Describe the bug
In Gutenberg 6.5.
Shows this error in the console :
react-dom.min.b694e242.js:103 TypeError: Cannot read property 'trim' of undefined

To reproduce

  1. Copy text from a source where there is a tag with no href
    or
    create a link with no href when editing a block in HTML mode
  2. In visual mode, click on the link or drag over it (like when you want to select text containing a anchor with no href).
  3. Oups, block is gone!

Expected behavior
The pop-up to enter the adress should show up empty

Desktop:

  • OS: Windows 10
  • Browser: Chrome
  • Version: 77

Thank you!

@swissspidy swissspidy added [Block] Paragraph Affects the Paragraph Block [Type] Bug An existing feature does not function as intended Needs Testing Needs further testing to be confirmed. labels Oct 1, 2019
@glendaviesnz
Copy link
Contributor

glendaviesnz commented Oct 14, 2019

Have tested this and it is easy to replicate on latest master using the steps outlined above.

The problem is that https://github.com/WordPress/gutenberg/blob/master/packages/url/src/index.js#L362 doesn't check for an undefined value being passed in.

It would probably make sense to check here that url is defined before running .trim, but none of the other methods in this file check the params so maybe it is a deliberate decision to leave checking to the callers. Also, changing this method would require updating the related index.d.ts to allow undefined or false as an optional return type ... so the quicker/easier fix of checking at the caller end is added in the following PR - #17928

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Paragraph Affects the Paragraph Block Needs Testing Needs further testing to be confirmed. [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants