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

Unlinking text throws error Cannot read property 'index' of undefined #1259

Closed
JedWatson opened this issue Jan 12, 2017 · 10 comments
Closed

Comments

@JedWatson
Copy link

JedWatson commented Jan 12, 2017

Removing a link throws a JavaScript Error:

Uncaught TypeError: Cannot read property 'index' of undefined

Steps for Reproduction

  1. Visit http://codepen.io/anon/pen/ygOXBV - This is a simple port of the code in the quickstart guide

  2. Link some text using the link button in the toolbar. It will be selected and go blue.

  3. Reposition the cursor away from the link then back into the link to get the in-context link popover. Click the "remove" link in the popover.

Expected behavior:

The link is removed

Actual behavior:

The link is not removed, and an error will be logged to the JavaScript console in the browser:

screen shot 2017-01-12 at 5 42 35 pm

Note: If you reselect the entire linked text (the link button on the toolbar will go blue) and click the button in the toolbar, it will successfully remove the link. The error only occurs using the "remove" link in the edit link popover.

Platforms:

macOS Sierra 10.12.1

Tested in Safari 10.0.1 (12602.2.14.0.7) and Chrome 55.0.2883.95 (64-bit)

Version:

This bug appears to be a regression with 1.1.9

By reverting the version loaded from the cdn to either 1.1.8 or 1.1.0 in the codepen, I can't reproduce it.

@jhchen
Copy link
Member

jhchen commented Jan 13, 2017

I'm not able to reproduce this on macOS 10.12.2 Chrome 55. Is this happening for you consistently? Can anyone else reproduce consistently?

@CoenWarmer
Copy link

I can reproduce this on the provided Codepen. When the cursor is placed somewhere within the link, but no selection is made, and I click 'Remove' in the link popup, the link is not removed and the error is thrown in the console.

When I select the entire link and I press 'Remove' in the link popup, the link is successfully removed and no error is thrown.

Got this in Chrome 55.0.2883.95, MacOS 10.12.2.

@EladBet
Copy link

EladBet commented Jan 18, 2017

Reproduce on playground.
Happen to me with Chrome 55, on windows 10.
Same thing happen with Safari 8 & Chrome 55 on Mac Yosemite.
Work OK on FF and IE.

Appears to be a regression with 1.1.9

@EladBet
Copy link

EladBet commented Jan 19, 2017

I spend some time with this bug and found the source of the problem.
It was a commit called fix reference line 51 .

if (range.length === 0 && source === Emitter.sources.USER)
source = 'api'
Emitter.sources.USER = 'user'

Adding source === Emitter.sources.USER breaks the removal of the link format on some browsers .

Its probably fixes something else so I didn't PR.

@jhchen
Copy link
Member

jhchen commented Jan 19, 2017

How did you isolate that commit @EladBet ? It being the culprit makes no sense. Quill is not in scope in those functions so will cause an error to be thrown.

I'm still not able to reproduce. @JedWatson can you be more specific in your instructions? Which range of text to select, what to type into the link editor, did you hit enter or click to link, where precisely did you click to click away, and where precisely did you click within the link to the the link tooltip to show up. Also please disable all browser extensions and confirm.

@EladBet
Copy link

EladBet commented Jan 21, 2017

Notice @jhchen its not an edge case it is very easy to reproduce just make sure you follow the prerequisites.

Prerequisites

Chrome 55, on windows 10.
Same thing happen with Safari 8 & Chrome 55 on Mac Yosemite.

Steps for Reproduction

  1. Visit playground/#autosave
  2. Find the link "http://en.wikipedia.org/wiki/One_Ring" in the second line.
  3. Click on it on the first word (or any other word), the tooltip bubble will popup.
  4. Click the remove button.

Actual behavior

  • The error mention before ('index' of undefined) will be displayed on the console

  • The link styling wan't change and will stay the same like nothing was happen.

*** A few times it didn't happen to me on the first time, but after refreshing the page it happen again.

  • Illustration to reproduce
    error
  • In the picture you can see how I debugged the code and find the problematic row.
    debugger

@stewartmacgregor
Copy link

@jhchen I am also experiencing this bug on a Mac with Chrome 56.0

screen shot 2017-02-14 at 4 13 29 pm

It appears to happen sporadically for me.

@dmitryuv
Copy link

happens always on Quill playground at the homepage, Mac with Chrome 56

@jhchen jhchen closed this as completed in e813d06 Feb 26, 2017
@jhchen
Copy link
Member

jhchen commented Feb 26, 2017

In case it is useful the intermittent vs consistent depends on how fast you click. Fast clickers never experience this because focus never shifts to the tooltip and slow clickers always experience this bug.

@valerielu
Copy link

valerielu commented Mar 10, 2017

I am experiencing this on mac chrome 56. Seeing the same the behavior where if you click faster it unlinks properly, whereas if you are a bit slower it results in the below error.
Also confirmed in my case that it you highlight the entire link and click the link icon it unlinks properly, doesnt matter your click speed.
screen shot 2017-03-09 at 3 58 04 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants