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

[Bug]: Unable to queryselectorAll listitems #5003

Closed
1 of 2 tasks
shaileshiyer opened this issue Mar 21, 2024 · 3 comments · Fixed by #5038
Closed
1 of 2 tasks

[Bug]: Unable to queryselectorAll listitems #5003

shaileshiyer opened this issue Mar 21, 2024 · 3 comments · Fixed by #5038
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug

Comments

@shaileshiyer
Copy link

Which packages did you experience the bug in?

core

What Tiptap version are you using?

2.2.4

What’s the bug you are facing?

if any one else also has weird query selectorAll bug with lists or is it just something specific to my build and setup that is breaking it. Since I am using tiptap inside the shadowDOM with lit-html and mobx. Since selecting list items becomes a pain without being able to use the query selector.

// get a bullet list from your doc
const $bulletList = editor.$node('bulletList')

// get all listItems from your bulletList
// This query selector returns an empty array
const $listItems = $bulletList.querySelectorAll('listItem')

// get the last listItem
const $lastListItem = $listItems[0]

when I checked why the call was failing it turns out that because the bulletList is a block item it prevents access to the its children in the querySelector call.

What browser are you using?

Edge

Code example

No response

What did you expect to happen?

Get a list of nodePositions for the list Items

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. 💖
@shaileshiyer shaileshiyer added Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug labels Mar 21, 2024
@github-project-automation github-project-automation bot moved this to Triage open in Tiptap Mar 21, 2024
@aleversn
Copy link

Same here, it seems that only a few nodes like paragraph, and codeBlock can be found.

@shaileshiyer
Copy link
Author

It seems like this bug was introduced with the feature to support block nodes. In 2.2.1 so rolling back the version to 2.2.0 fixed it. In case you are looking for a fix for it.

@needhourger
Copy link

querySelectorAll not support for custom node?
I defined my node using Node.create(name:'break') , however editor.$doc.querySelectorAll('break') always return empty array, and querySelector('break') return null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants