web-components icon indicating copy to clipboard operation
web-components copied to clipboard

Linebreak in lists do not work correctly

Open d-e-v-esh opened this issue 3 years ago • 15 comments

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

d-e-v-esh avatar Mar 08 '21 08:03 d-e-v-esh

@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

K-Kumar-01 avatar Mar 08 '21 17:03 K-Kumar-01

@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.

d-e-v-esh avatar Mar 09 '21 02:03 d-e-v-esh

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

Cronus1007 avatar Mar 10 '21 13:03 Cronus1007

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

jolanglinais avatar Mar 10 '21 20:03 jolanglinais

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

d-e-v-esh avatar Mar 11 '21 04:03 d-e-v-esh

@irmerk Can you assign it to me please?

Hanaffi avatar Mar 13 '21 15:03 Hanaffi

@Hanaffi please see https://github.com/accordproject/web-components/issues/284#issuecomment-796089929

jolanglinais avatar Mar 15 '21 15:03 jolanglinais

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

dezfuture avatar Mar 26 '21 12:03 dezfuture

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

K-Kumar-01 avatar Mar 26 '21 12:03 K-Kumar-01

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

K-Kumar-01 avatar Apr 09 '21 18:04 K-Kumar-01

I believe #270 needs to be finished first.

jolanglinais avatar May 05 '21 15:05 jolanglinais

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

AbhishekJamhoriya avatar Oct 09 '21 22:10 AbhishekJamhoriya

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

jolanglinais avatar Nov 30 '21 21:11 jolanglinais

Can i work on this issue?

vikasazad avatar Dec 06 '21 07:12 vikasazad

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

TC5022 avatar Dec 06 '21 13:12 TC5022