Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

.can() returns false for extension-list even when the command is runnable #3229

Closed
1 of 2 tasks
C-Hess opened this issue Sep 24, 2022 · 4 comments
Closed
1 of 2 tasks
Labels
Info: Stale The issue or pullrequest has not been updated in a while and might be stale Type: Bug The issue or pullrequest is related to a bug

Comments

@C-Hess
Copy link
Contributor

C-Hess commented Sep 24, 2022

What’s the bug you are facing?

The .can() command is a bit overzealous for the list extension. If the cursor/selection is on an existing list or heading element, the can() command returns false for toggleBulletList() and toggleOrderedList() commands. However, these commands are still executable, and can/will replace the current node with the new list node type selected.

Which browser was this experienced in? Are any special extensions installed?

  • Chrome
  • Bullet lists
  • Ordered lists
  • Headings

How can we reproduce the bug on our side?

  1. Open the sandbox
    1. The sandbox is similar to the demo. The only difference is that the buttons are disabled if the can() command for the corresponding controls returns false
  2. Create a bullet or ordered list with one item in the list
  3. Note that the other list type and heading are disabled
  4. Create another list item at the same level
  5. Note that if the second list item in a list is selected with the cursor, they are enabled again
  6. Nest the second list item with the tab key
  7. Note that if two list items exist, but the cursor is on the first list item, the header is disabled 😕

Can you provide a CodeSandbox?

https://codesandbox.io/s/frosty-goldwasser-visq8r?file=/src/App.tsx

What did you expect to happen?

The .can() command should accurately reflect whether a command is possible to run given the editor state. In this case, because it is totally possible to switch between lists or convert a list to a heading, the .can() command should return true for all of the described cases above.

Anything to add? (optional)

It's possible that the heading being disabled when the nested list item is selected is a separate issue, but I figured I'd leave it here in case it's the same. Otherwise, let me know, and I can open another issue

This issue is related to #3223, but that pr fixes issues with the .can() command for marks

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. 💖
@C-Hess C-Hess added the Type: Bug The issue or pullrequest is related to a bug label Sep 24, 2022
@github-actions
Copy link
Contributor

This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Info: Stale The issue or pullrequest has not been updated in a while and might be stale label Dec 24, 2022
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 31, 2022
@bkempe
Copy link

bkempe commented Mar 30, 2023

This is still an issue

@corbinschwartz
Copy link

corbinschwartz commented Mar 31, 2023

Also running into this, repro steps in original description are accurate.

#3026 looks potentially related:

@Goodosky
Copy link

Goodosky commented Apr 14, 2024

The same problem occurs with setHeading() and toggleHeading()

If the selection is on an existing list, both commands are runnable, but .can() returns false.

This issue has been around for some time: #4225 (comment)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Info: Stale The issue or pullrequest has not been updated in a while and might be stale Type: Bug The issue or pullrequest is related to a bug
Projects
None yet
Development

No branches or pull requests

4 participants