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

exitBreakPlugin bug when allow is missing in config #3360

Open
TrySpace opened this issue Jul 13, 2024 · 0 comments
Open

exitBreakPlugin bug when allow is missing in config #3360

TrySpace opened this issue Jul 13, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@TrySpace
Copy link

TrySpace commented Jul 13, 2024

Description

When using the exitBreakPlugin, I've encountered an issue with the handling of the Enter key in list items. The plugin works as expected when the allow option is specified, but if allow is omitted, it deletes the text within list items.

Current Behavior

With allow specified for headings:
Pressing Enter after a list item creates a new list item (desired behavior).

Without allow specified:

Pressing Enter in a list item deletes the text in the current list item instead of creating a new list item (but not the list item node itself)

The rest of the exitBreakPlugin works fine with heading and other cases where you want to hard exit out of by default with enter.

It's possible that using exclude for ELEMENT_LI would workaround this issue, but it should not delete the items to begin with.

Reproduction URL

No response

Reproduction steps

Set up a Plate.js editor with the exitBreakPlugin.
Configure the plugin as follows:

import { createExitBreakPlugin } from '@udecode/plate-break';
import { ELEMENT_H1, ELEMENT_H2, ELEMENT_H3 } from '@udecode/plate';

export const exitBreakPlugin = createExitBreakPlugin({
  options: {
    rules: [
      {
        hotkey: 'enter',
        query: {
          start: true,
          end: true,
          allow: [ELEMENT_H1, ELEMENT_H2, ELEMENT_H3], // Comment out this line to reproduce the issue
        },
        relative: true,
        level: 0,
      },
    ],
  },
});
  1. Create a list item.
  2. Test pressing Enter within list items.
  3. Comment out the allow line and repeat the test.


### Plate version

33.0.0

### Slate React version

0.104.0

### Browsers

Chrome
@TrySpace TrySpace added the bug Something isn't working label Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant