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

editor.isActive shows both bulletList and orderedList active for a nested ordered list inside an unordered list #2475

Closed
2 tasks done
JonathanKolnik opened this issue Feb 2, 2022 · 3 comments
Labels
Type: Bug The issue or pullrequest is related to a bug

Comments

@JonathanKolnik
Copy link

What’s the bug you are facing?

When you have a nested list of ordered and unordered like
image

and you select the nested line you end up with both editor.isActive('bulletList') and editor.isActive('orderedList') as true

image

How can we reproduce the bug on our side?

I made a sandbox

Can you provide a CodeSandbox?

https://codesandbox.io/s/amazing-paper-mefbe?file=/src/App.js

What did you expect to happen?

I expect that if I'm on a bulleted line then only isActive('bulletList') is true and it is not affected by the parent

Anything to add? (optional)

No response

Did you update your dependencies?

  • Yes, I’ve updated my dependencies to use the latest version of all packages.

Are you sponsoring us?

  • Yes, I’m a sponsor. 💖
@JonathanKolnik JonathanKolnik added the Type: Bug The issue or pullrequest is related to a bug label Feb 2, 2022
@philippkuehn
Copy link
Contributor

This is expected and I don’t want to change that.

Lists are complex nested structures. In your case isActive('bulletList'), isActive('orderedList'), isActive('listItem') and isActive('paragraph') returns true. I could imagine that only the closest block node is checked in isActive, but this would be paragraph in this case, which you would also not expect.

You have to write your own method to handle these specific cases.

@inickvel
Copy link

There is a solution for this problem
#1058 (comment)

@bkempe
Copy link

bkempe commented Feb 11, 2022

Or maybe

  const { extensionManager, state } = editor;
  const { extensions } = extensionManager;
  const { selection } = state;
  // see https://github.com/ueberdosis/tiptap/blob/10248f276320d39fb0fd0cc6786ae2de4d219ec7/packages/core/src/commands/toggleList.ts#L86
  const parentList = findParentNode(node => isList(node.type.name, extensions))(
    selection,
  );
  return parentList !== undefined && parentList.node.type.name === nodeType;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug The issue or pullrequest is related to a bug
Projects
None yet
Development

No branches or pull requests

4 participants