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 bug interacting with and hovering over table columns in read-only mode #49

Merged
merged 2 commits into from
Jun 16, 2023

Conversation

sjdemartini
Copy link
Owner

There was a mistake in the original approach, since setting "display: none" on &.resize-cursor would actually be hiding the entire ProseMirror document, as opposed to some cursor element. This didn't appear very obviously in Chrome (though there were times where you could get it to flash slightly when hovering over a column divider), but in Firefox it was much more drastic, where the content would disappear/reappear, causing the page scroll position to rapidly/unexpectedly change any time a user's cursor crossed over a column border.

Also, it was still possible to drag and resize a column, despite it being in read-only mode and not showing a resize cursor, since the editor and the table were still responding to pointer events (and the underlying prosemirror-tables columnResizing plugin doesn't know/care about editable state). This now turns off pointer events to the entire table if the "resize-cursor" class appears, which more thoroughly prevents any column resizing from happening. Fortunately, the table cells themselves are still selectable via the tableEditing plugin, so users can highlight vertically/horizontally across table cells even in read-only mode, since "resize-cursor" only appears when hovering specifically over the border.

… mode

There was a mistake in the original approach, since setting `"display:
none"` on `&.resize-cursor` would actually be hiding the entire
ProseMirror document, as opposed to some cursor element. This didn't
appear very obviously in Chrome (though there were times where you could
get it to flash slightly when hovering over a column divider), but in
Firefox it was much more drastic, where the content would
disappear/reappear, causing the page scroll position to
rapidly/unexpectedly change any time a user's cursor crossed over a
column border.

Also, it was still possible to drag and resize a column, despite it
being in read-only mode and not showing a resize cursor, since the
editor and the table were still responding to pointer events (and the
underlying prosemirror-tables `columnResizing` plugin doesn't know/care
about `editable` state). This now turns off pointer events to the entire
table if the `"resize-cursor"` class appears, which more thoroughly
prevents any column resizing from happening. Fortunately, the table
cells themselves are still selectable via the `tableEditing` plugin, so
users can highlight vertically/horizontally across table cells even in
read-only mode, since `"resize-cursor"` only appears when hovering
specifically over the border.
@sjdemartini sjdemartini merged commit f942cf2 into main Jun 16, 2023
@sjdemartini sjdemartini deleted the fix-bug-in-read-only-table-column-hover branch June 16, 2023 22:23
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.

None yet

1 participant