Gutenberg: Format Library: Error after adding link to text

Created on 8 Jan 2019  ·  5Comments  ·  Source: WordPress/gutenberg

Describe the bug

I'd encountered an error upon steps following the addition of a link to text. The "To Reproduce" is one way, though it was not specifically the one I recall being the original set of steps, so there may be other potential ways for the error to be triggered.

To Reproduce

Steps to reproduce the behavior:

Pre-requisite: Copy a link to your clipboard (like the URL of this issue)

  1. Navigate to Posts > Add New
  2. Add a paragraph block with the text "Link."
  3. Press Enter to create a new block.
  4. Double click "Link" in the first paragraph to select the text
  5. Paste to apply the link
  6. Click below the second paragraph block
  7. Press Backspace
  8. Observe that the block encounters an error.

Screenshot:

image

Error Text:

TypeError: Cannot read property 'top' of undefined
    at getCurrentCaretPositionStyle (positioned-at-selection.js:25)
    at new PositionedAtSelection (positioned-at-selection.js:51)
    at zf (react-dom.min.713f0afa.js:69)
    at Mf (react-dom.min.713f0afa.js:87)
    at ph (react-dom.min.713f0afa.js:98)
    at eg (react-dom.min.713f0afa.js:125)
    at fg (react-dom.min.713f0afa.js:126)
    at wc (react-dom.min.713f0afa.js:138)
    at fa (react-dom.min.713f0afa.js:137)
    at ng (react-dom.min.713f0afa.js:149)
Pf @ react-dom.min.713f0afa.js:104

Error Location:

https://github.com/WordPress/gutenberg/blob/8cce5f2b3910f88cc576b27b3290bbcc89e8fd0a/packages/format-library/src/link/positioned-at-selection.js#L25

[Package] Format library [Type] Bug

All 5 comments

I tried testing this with 5.0.2 and 5.0.3 using Chrome 71.0.3578.98 and Firefox 64.0 on macOS 10.13.6 and I couldn't replicate the problem. (10s) (I must be missing something in my steps!)

@designsimply I suspect from your video the key difference being in that, at Step 6, you clicked specifically on the second block, not below it. In my testing, this seems enough to make a difference.

Aha, you are correct! Thanks for catching that and following up. 🤦‍♀️ I totally read step 6 as "Click below the first paragraph block" not "Click below the second paragraph block"!

Re-tested with WordPress 5.0.4-alpha-44523 and confirmed:

13243-13s

@aduth Is this issue still present after the removal of PositionedAtSelection? I can't reproduce any longer.

@aduth Is this issue still present after the removal of PositionedAtSelection? I can't reproduce any longer.

It appears to be fixed! Thanks for checking.

Was this page helpful?
0 / 5 - 0 ratings