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

FIX: Fix an issue with cursor jump in table cell #155

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

deniszografski
Copy link

@deniszografski deniszografski commented Mar 15, 2023

@marijnh
I encountered a problem when the user wants to choose a different cell and in condition that the previous one has some content.

I also recorded a short gif demonstrating the problem
ezgif com-optimize

and I also made a solution as part of this PR.

P.S.
It may not be in line with the best practices of the whole lib but it can serve as an inspiration for a potential fix. Thanks in advance.

Stack:

  • browser: Google Chrome Version 111.0.5563.64
  • prosemirror-view- 1.30.2
  • prosemirror-collab - 1.30.0
  • prosemirror-tables - 1.2.5

@marijnh
Copy link
Member

marijnh commented Mar 15, 2023

Could you describe the problem this is intended to fix in a bit more detail?

@deniszografski
Copy link
Author

deniszografski commented Mar 15, 2023

@marijnh
Yes, of course.

I would like to have the same behavior as it was in version prosemirror-view- 1.25.0.

I would like to click anywhere within the table cell to stay in that table cell without changing my selection and thus performing the position of the cursor in the next cell.

If you look at the gif I recorded, you can notice that every time I click on the cell, the cursor ends up in the cell next to it unless I focus on the very beginning of the cell. In this case, the cursor remains in that, selected cell.

I hope I was able to explain the problem more closely.

UPDATE

I can confirm that my current solution will just prevent execution of this part of source code:
updateSelection(this.view, Selection.near(this.view.state.doc.resolve(pos.pos)), "pointer") event.preventDefault()

which causes the expected behavior of selection.

I'm aware that the solution must be more sophisticated and precise.
Could we at least open a bug for that problem?

@deniszografski deniszografski marked this pull request as draft March 15, 2023 15:08
@marijnh
Copy link
Member

marijnh commented Mar 16, 2023

I cannot reproduce the problem you are describing. This happens in Chrome, right, when you click around to move the cursor between adjacent empty cells?

@deniszografski
Copy link
Author

deniszografski commented Mar 16, 2023

@marijnh

Exactly, only in Chrome.

But after debugging I noticed that almost every time this.view.state.selection.visible is undefined.
I'll definitely have to look into how that happens.

Maybe updating the table module will fix the problem. ¯_(ツ)_/¯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants