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

Enter on Heading Text - Cursor Jump #260

Open
d-e-v-esh opened this issue Feb 23, 2021 · 5 comments
Open

Enter on Heading Text - Cursor Jump #260

d-e-v-esh opened this issue Feb 23, 2021 · 5 comments

Comments

@d-e-v-esh
Copy link
Contributor

Bug Report 🐛

The cursor would jump one line above when we would press enter from the beginning of any heading text

r91hU4x2ti

Expected Behavior

The cursor should go down with the heading text as it happens everywhere else

Steps to Reproduce

  1. Put the cursor to the beginning of any heading and press enter.

Desktop

  • OS: Windows 10
  • Browser: Chrome
  • Version 88.0.4324.182 (Official Build) (64-bit)
@jolanglinais jolanglinais changed the title 🐛 insertHeadingbreak Bug Enter on Heading Text - Cursor Jump Feb 23, 2021
d-e-v-esh added a commit to d-e-v-esh/web-components that referenced this issue Feb 24, 2021
@d-e-v-esh
Copy link
Contributor Author

@irmerk This problem is occurring because:
When we press enter from the start of the heading word => it inserts a line above the heading line by default instead of below.
This only happens when we insert from the start of the line. It works perfectly when we do it from the middle or the end of the heading word.
The fix for this can be:

  1. Whenever headingbreak is called => the next line node it inserts down below would be converted into a paragraph.
  2. This creates a new problem where if we press enter from the beginning of the heading word, the heading would be converted into a paragraph too.
  3. To fix that=> Override the default insertbreak() in the headingbreak function and tell it to do the above 1. only when it is at the end of the line. We create a point for the end of the heading line and make a conditional to check if the insetbreak() is being called from the stored end of the line point and execute 1 if that is true.

Is that an appropriate solution?

@jolanglinais
Copy link
Member

If I understand correctly, I think that sounds good. I think we want:

  • ENTER at BEGINNING of node (where ↑ is) creates a new line of the same text:
<h1>Heading</h1>
<p>Normal paragraph text.</p>

Becomes this with the cursor (↑) positioned:

<h1></h1>
<h1>Heading</h1>
<p></p>
<p>Normal paragraph text.</p>

  • ENTER at MIDDLE of node (where ↑ is) creates a new line of similar text, essentially splitting the node:
<h1>Heading</h1>
<p>Normal paragraph text.</p>

Becomes this with the cursor (↑) positioned:

<h1>Hea</h1>
<h1>ding</h1>
<p>Norm</p>
<p>al paragraph text.</p>

  • ENTER at END of node (where ↑ is) creates a new line of normal paragraph text:
<h1>Heading</h1>
<p>Normal paragraph text.</p>

Becomes this with the cursor (↑) positioned:

<h1>Heading</h1>
<p></p>
<p>Normal paragraph text.</p>
<p></p>

@d-e-v-esh
Copy link
Contributor Author

d-e-v-esh commented Mar 5, 2021

@irmerk Yes, that is exactly how it needs to work. I can make a sample work but making a PR would not make sense until we fix this #270 issue.

@d-e-v-esh
Copy link
Contributor Author

@irmerk Can you please check the updates that I made in the description of #270. Any feedback would be really appreciated.

d-e-v-esh added a commit to d-e-v-esh/web-components that referenced this issue Apr 3, 2021
d-e-v-esh added a commit to d-e-v-esh/web-components that referenced this issue May 5, 2021
@d-e-v-esh
Copy link
Contributor Author

d-e-v-esh commented May 8, 2021

@irmerk I have fixed this issue locally. I can make a pull request after the #270 is resolved and merged.

Qt3NU2DABz

d-e-v-esh added a commit to d-e-v-esh/web-components that referenced this issue Oct 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants