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

When a table is the last node in the document and its last cell is empty, Ctrl+A fails to select anything but the first node of the document. #2401

Closed
1 of 2 tasks
andriisharshakov opened this issue Jan 18, 2022 · 9 comments
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

@andriisharshakov
Copy link

What’s the bug you are facing?

When:

  • a table is the last node in the document
  • that table's last cell is empty

Ctrl+A will select the first node of the document.
image

If the last cell of that table has any content, Ctrl+A will select everything as expected.
image

How can we reproduce the bug on our side?

  • open the document
  • add any paragraphs or other nodes
  • add a table as the last node
  • hit Ctrl+A to ensure "select all" works
  • leave the table blank OR only leave table's last (= bottom right) cell empty
  • hit Ctrl+A again to ensure "select all" will only select the first node in the document

Can you provide a CodeSandbox?

https://codesandbox.io/s/suspicious-swartz-xfx53?file=/src/App.js

What did you expect to happen?

I expect Ctrl+A to select all the nodes in the document, but it doesn't depending on table node's contents.

Anything to add? (optional)

First, I wanted to ensure where this behavior is coming from. So, I've tried to reproduce this on the clean demo of prosemirror-tables extension - but it works fine.

Though on this tiptap demo it works exactly as in my project, i.e. "select all" is broken for the described scenario.

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. 💖
@andriisharshakov andriisharshakov added the Type: Bug The issue or pullrequest is related to a bug label Jan 18, 2022
@jpobley
Copy link
Contributor

jpobley commented Jan 27, 2022

Updating the selectAll command to use the AllSelection class from prosemirror-state fixes this issue, but I don't know why: jpobley@61794de.

Something about how setTextSelection is resolving the range of the doc, but I can't understand why the TextSelection jumps to the first node in the doc.

I'm happy to open a PR but would love to understand what's causing the issue and even write a test about it if possible.

@philippkuehn
Copy link
Contributor

philippkuehn commented Jan 27, 2022

@jpobley AllSelection leads to some other strange bugs. See #1908

Not sure what’s going on here right now. I'm looking into it.

@jpobley
Copy link
Contributor

jpobley commented Jan 27, 2022

Oooooooh, yeah, I thought there might be dragons elsewhere. Thanks for the education, @philippkuehn.

@philippkuehn
Copy link
Contributor

I had to revert these changes because of #2491
I haven't found another fix yet and think it's a ProseMirror bug.

@philippkuehn philippkuehn reopened this Feb 7, 2022
@philippkuehn
Copy link
Contributor

The issue is within the prosemirror-tables plugin.

https://github.com/ProseMirror/prosemirror-tables/blob/6b16ed3cf306886f2c169aebbe60701e1ac2deac/src/cellselection.js#L290-L292

Unfortunately this packages isn’t maintained anymore :(

@Moondas
Copy link

Moondas commented May 30, 2022

@stale
Copy link

stale bot commented Jul 29, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 29, 2022
@svenadlung svenadlung removed the stale label Aug 1, 2022
@jpobley
Copy link
Contributor

jpobley commented Aug 10, 2022

I updated my dependencies recently and noticed that the table extension is now using a fork at @_ueberdosis/prosemirror-tables. Does this mean the TipTap team is moving towards being able to fix this issue on their fork?

@github-actions
Copy link
Contributor

github-actions bot commented Nov 9, 2022

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 Nov 9, 2022
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 17, 2022
thet added a commit to Patternslib/pat-tiptap that referenced this issue Oct 13, 2023
There is a strange problem with tables and selecting all content with
<ctrl>-<a>. When the last node in the document is a table and the last
table cell is empty, then pressing <CTRL>-<a> to select everyting only
selects the very first node in the document. As soon as one of the
conditions - table not the last node or last table cell not empty - is
not met, <CTRL>-<a> selects all, as expected.

We fix the problem by making sure some content is following the table
and add an empty paragraph. When another solution is found we can remove
this hack again.

More information here:
- ueberdosis/tiptap#2401
- ueberdosis/tiptap#3651
thet added a commit to Patternslib/pat-tiptap that referenced this issue Oct 13, 2023
There is a strange problem with tables and selecting all content with
<ctrl>-<a>. When the last node in the document is a table and the last
table cell is empty, then pressing <CTRL>-<a> to select everyting only
selects the very first node in the document. As soon as one of the
conditions - table not the last node or last table cell not empty - is
not met, <CTRL>-<a> selects all, as expected.

We fix the problem by making sure some content is following the table
and add an empty paragraph. When another solution is found we can remove
this hack again.

More information here:
- ueberdosis/tiptap#2401
- ueberdosis/tiptap#3651
thet added a commit to Patternslib/pat-tiptap that referenced this issue Oct 23, 2023
Allow to select all (Ctrl-A, Command-A) with tables in certain
conditions.
Due to a tiptap/ProseMirror bug tables with some empty cells and no
content preceding or following the table, selecting the whole table did
not work. This fix makes sure that a non-empty paragraph is added at the
end, if no other content is present at the end of the document.

More information here:
- ueberdosis/tiptap#2401
- ueberdosis/tiptap#3651
thet added a commit to Patternslib/pat-tiptap that referenced this issue Oct 23, 2023
Allow to select all (Ctrl-A, Command-A) with tables in certain
conditions.
Due to a tiptap/ProseMirror bug tables with some empty cells and no
content preceding or following the table, selecting the whole table did
not work. This fix makes sure that a non-empty paragraph is added at the
end, if no other content is present at the end of the document.

Follow-up from:
- #61

More information here:
- ueberdosis/tiptap#2401
- ueberdosis/tiptap#3651
Sign up for free to join this conversation on GitHub. Already have an account? Sign in 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

5 participants