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

Linebreak in lists do not work correctly #284

Open
d-e-v-esh opened this issue Mar 8, 2021 · 16 comments
Open

Linebreak in lists do not work correctly #284

d-e-v-esh opened this issue Mar 8, 2021 · 16 comments

Comments

@d-e-v-esh
Copy link
Contributor

Bug Report 🐛

When we press Enter in the middle of a sentence inside of a list, instead of pushing the rest of the sentence to the new line, it inserts a new line and then pushes the rest of the sentence to the new line which creates an extra unneeded line that can be very annoying at times for the user.

Expected Behavior

It should push the rest of the text to the next number without inserting an extra new line
z46wT6RZtq

Current Behavior

It inserts a new line and then pushes the rest of the paragraph to the next number.

i5wYoJlNwG

Possible Solution

Steps to Reproduce

  1. Paste a sample paragraph into the editor.
  2. Click on the numbered list button in the toolbar
  3. Now that the entire paragraph is under number 1 in the list, go to the end of the first line and press Enter
  4. You would see an extra line that should not be there.

Context (Environment)

Desktop

  • OS: Windows 10
  • Browser: Chrome
  • Version 88.0.4324.182 (Official Build) (64-bit)

Detailed Description

Possible Implementation

@K-Kumar-01
Copy link
Contributor

K-Kumar-01 commented Mar 8, 2021

@dselman
I looked into the issue and here I am facing some difficulties.

const onKeyDown = useCallback((event) => {
    if (!canKeyDown(editor, event)) {
 const onKeyDown = useCallback((event) => {
    if (!canKeyDown(editor, event)) {
      event.preventDefault();
      return;
    }
    console.log(event.key);

    const isFormatEvent = () => formattingHotKeys.some(hotkey => isHotkey(hotkey, event));
    
    if (!canBeFormatted(editor) && isFormatEvent()) {
      event.preventDefault();
      return;
    }

    if (event.key === "Enter" && !isBlockHeading(editor)) {
      return;
    }    
    console.log('isFormatEvent',isFormatEvent())
    const hotkeys = Object.keys(HOTKEYS);
    hotkeys.forEach((hotkey) => {      
      if (isHotkey(hotkey, event)) {
        event.preventDefault();
        const { code, type } = HOTKEYS[hotkey];
        console.log(code,type);
        hotkeyActions[type](code);
      }
    });
  }, [canBeFormatted, canKeyDown, editor, hotkeyActions]);

On pressing the Enter key there is no console.log():
On pressing other keys(not hotkeys) there is console.log();
On pressing shortcut(hotkeys) keys, there is console.log() both times.

Screenshot from 2021-03-08 22-08-22
I am unable to understand as why there is no log when we press Enter key. Need help here

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

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

@K-Kumar-01 That is because of this line here

    if (event.key === "Enter" && !isBlockHeading(editor)) {
      return;
    }

It basically means that if you are on a non-heading block and you press enter then everything should be ignored. I have detailed this issue and its solution in this pull request here #270
If you comment out that line then the console.log will work.
This problem is causing few other problems in the issues list.

@Cronus1007
Copy link
Contributor

@d-e-v-esh Shall I work upon this issue.

@jolanglinais
Copy link
Member

I suspect we hold off on this Issue specifically until #270 is finished and then see where we stand.

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

@irmerk Yes, I think that would be the best.

@Hanaffi
Copy link

Hanaffi commented Mar 13, 2021

@irmerk Can you assign it to me please?

@jolanglinais
Copy link
Member

@Hanaffi please see #284 (comment)

@dezfuture
Copy link

I would like to contribute and fix the issue.
Can you guide me on how should I go forward into solving this issue

@K-Kumar-01
Copy link
Contributor

@dezfuture
The issue #270 needs to be finished before you can pick up this issue

@K-Kumar-01
Copy link
Contributor

@irmerk
Since this issue is unblocked, I would like to work on it,

@jolanglinais
Copy link
Member

I believe #270 needs to be finished first.

@AbhishekJamhoriya
Copy link

@d-e-v-esh can i work on this issue.

@jolanglinais
Copy link
Member

@AbhishekJamhoriya please open a PR if you work on this.

@vikasazad
Copy link

Can i work on this issue?

@TC5022
Copy link
Contributor

TC5022 commented Dec 6, 2021

@d-e-v-esh I would like to work on this issue, if it's still open

@Utkarshpandey0001
Copy link

is this issue still open ? i want to work on this issue . if it still exists , then please can you assign this issue to me ?

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