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

Pressing backspace at the beginning of the first paragraph resets the block incorrectly #3328

Closed
ZzzZeta opened this issue Jul 4, 2024 · 10 comments
Labels
bug Something isn't working

Comments

@ZzzZeta
Copy link

ZzzZeta commented Jul 4, 2024

Description

Pressing backspace at the beginning of the first block resets the node (reset node plugin) incorrectly.

It causes

  • node id to disappear
  • ul and ol to transform to p

Original value:

[
  {
    type: "p",
    id: "8h1e2",
    children: [
      {
        text: "",
      },
    ],
  },
];

After pressing BACKSPACE:

[
  {
    children: [
      {
        text: "",
      },
    ],
    type: "p",
  },
];

Reproduction URL

https://github.com/udecode/plate-playground-template

Reproduction steps

1. Run playground template or open https://platejs.org/.
2. Press `ENTER` on first block to create 2 paragraph.
3. Press `BACKSPACE` on first paragraph.
4. Type something on the paragraphs.
5. Drag to swap orders multiple times to see one of the paragraph content disappear.

Plate version

34.0.4

Slate React version

0.103.0

Screenshots

No response

Logs

Original:

[
  {
    type: "p",
    id: "8h1e2",
    children: [
      {
        text: "",
      },
    ],
  },
];

After pressing BACKSPACE:

[
  {
    children: [
      {
        text: "",
      },
    ],
    type: "p",
  },
];

Browsers

Chrome, Firefox

Funding

  • You can sponsor this specific effort via a Polar.sh pledge below
  • We receive the pledge once the issue is completed & verified
Fund with Polar
@ZzzZeta ZzzZeta added the bug Something isn't working label Jul 4, 2024
@ZzzZeta ZzzZeta changed the title Press backspace on first paragraph cause node to recreate with no node id Press backspace on first paragraph (if empty) recreate a paragraph without node id Jul 4, 2024
@ZzzZeta ZzzZeta changed the title Press backspace on first paragraph (if empty) recreate a paragraph without node id Pressing backspace at the beginning of the first paragraph recreate the paragraph with no node id Jul 20, 2024
@ZzzZeta
Copy link
Author

ZzzZeta commented Aug 9, 2024

It is caused by reset node plugin. Enable disableFirstBlockReset fixes it.
When disableFirstBlockReset is not enabled, it even transforms list structure to p > li > lic and makes it broken.

@ZzzZeta ZzzZeta changed the title Pressing backspace at the beginning of the first paragraph recreate the paragraph with no node id Pressing backspace at the beginning of the first paragraph resets the block incorrectly Aug 9, 2024
@tyfyyhs
Copy link

tyfyyhs commented Sep 5, 2024

Pressing delete key at the beginning of the first paragraph resets the block incorrectly

@felixfeng33
Copy link
Collaborator

felixfeng33 commented Sep 5, 2024

Does it fixed by #3444 ? Could try update?
Update to @udecode/[email protected]

@mareksuscak
Copy link
Contributor

mareksuscak commented Sep 11, 2024

The Reset Plugin is buggy as hell. Try deleting all the content from the playground, then add an empty code block, hit backspace. You no longer see the placeholder which is shifted on to the next line and even if you delete it, there's no placeholder and the document is weirdly nested. You can also not use ``` anymore as it keeps resetting.

@zbeyens any idea what could be off? We just upgraded from v34 where this issue wasn't present and resetting worked correctly or at least better than in v37.

@felixfeng33
Copy link
Collaborator

The Reset Plugin is buggy as hell. Try deleting all the content from the playground, then add an empty code block, hit backspace. You no longer see the placeholder which is shifted on to the next line and even if you delete it, there's no placeholder and the document is weirdly nested. You can also not use ``` anymore as it keeps resetting.

@zbeyens any idea what could be off? We just upgraded from v34 where this issue wasn't present and resetting worked correctly or at least better than in v37.

It looks like the ResetNodePlugin was accidentally deleted in Playground. v37 should be fine as well. fixing now

@felixfeng33
Copy link
Collaborator

felixfeng33 commented Sep 11, 2024

The problem is ResetNodePlugin not import from '/react' fixes by #3522 This is indeed an easy issue to overlook and is often mentioned. We’ll include it in the documentation when we get the chance.

@felixfeng33
Copy link
Collaborator

should be fixed by #3444 or #3522

@mareksuscak
Copy link
Contributor

mareksuscak commented Sep 11, 2024

@felixfeng33 ya I noticed that while upgrading too. I wonder if it'd make sense to use different plugin names because it is indeed incredibly easy to overlook and so hard to troubleshoot when React and non-React plugins share the same name. Thanks for the fixes!

@12joan
Copy link
Collaborator

12joan commented Sep 11, 2024

@zbeyens Maybe we should rename the non-React plugins (or at least the ones that have React alternatives) with a prefix like "Headless" or "Slate"?

@ZzzZeta
Copy link
Author

ZzzZeta commented Sep 16, 2024

Does it fixed by #3444 ? Could try update? Update to @udecode/[email protected]

It still incorrectly resets table and list (the non indent one).

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

5 participants