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

Section header applied to following paragraph after delete #51

Open
adamwiggins opened this issue Jan 25, 2016 · 7 comments
Open

Section header applied to following paragraph after delete #51

adamwiggins opened this issue Jan 25, 2016 · 7 comments

Comments

@adamwiggins
Copy link
Contributor

Steps to reproduce:

  1. welcome notebook
  2. select "prose editor" through "csv data and charts"

screen shot 2016-01-25 at 17 16 29

1. press backspace 2. now the next paragraph ("Load the...") is a section header -- expect instead it should keep its style (regular paragraph/body text) intact

screen shot 2016-01-25 at 17 16 37

@brettimus
Copy link
Contributor

See replication steps for #26 (i.e., contenteditable is still weird)

@brettimus
Copy link
Contributor

Original p tag is not preserved, making this fairly hard to solve with a validation rule.

Alternative is to short circuit any delete operations and trim the selection by -1 if

  1. The selection has length > 0, &&
  2. The selection has dangling whitespace

The foregoing idea is possibly worth a shot but reeks of unintended consequences.

@brettimus
Copy link
Contributor

So, I have to try to replicate this issue to encounter it. I.e., I have to select the text and then press shift+right arrow.

Is anyone getting this error with standard delete operations?

cc @adamwiggins @luciasantamaria

@luciasantamaria
Copy link
Contributor

@brettimus To replicate: Put cursor before 'Live coding'. Hold Shift, press down arrow 3 times to select until end of 'Prose Editor'. Press delete. Then 'Navigate... ' gets Header style.

@brettimus
Copy link
Contributor

👍 thanks!

@brettimus
Copy link
Contributor

As of now it’s feeling like we’re bumping into contenteditable weirdness.

I’m not sure mediumeditor gives us enough control over editor contents to fix this. The medium selection API is returning unexpected results when I try debugging in the middle of replicating. 😖

@brettimus
Copy link
Contributor

Underlying conditions that cause this bug seem to be that

  • window.getSelection().toString() returns text with a trailing newline, and
  • window.getSelection().focusNode is a p tag that is not visibly included in the user's selection.

The focusNode is the node in which the selection ends.

MDN reference on selection api

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

No branches or pull requests

3 participants