-
Notifications
You must be signed in to change notification settings - Fork 31
fix(YfmTable): fixed positioning of floating controls when scrolling horizontally in table #887
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
base: main
Are you sure you want to change the base?
Conversation
|
Preview is ready. |
|
Visual Tests Report is ready. |
7bf4b75 to
40e4d76
Compare
…scrolled horizontally
40e4d76 to
68c55e2
Compare
68c55e2 to
2a4f6d1
Compare
| const rect = (tableNode as Element).getBoundingClientRect(); | ||
| table.style.width = rect.width + 'px'; | ||
| const tableNode = view.domAtPos(tableDesc.pos + 1).node; | ||
| isHorizontallyScrolled = (tableNode as Element).scrollLeft > 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| isHorizontallyScrolled = (tableNode as Element).scrollLeft > 0; | |
| isHorizontallyScrolled = tableNode instanceof Element && tableNode.scrollLeft > 0; |
| isHorizontallyScrolled = (tableNode as Element).scrollLeft > 0; | ||
|
|
||
| const tbodyNode = view.domAtPos(tableDesc.bodyPos + 1).node; | ||
| const tbodyRect = (tbodyNode as Element).getBoundingClientRect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
| // left border of table | ||
| if (cellMiddle - EDGE_OFFSET <= tableRect.left) { | ||
| const visible = cellRect.right - tableRect.left; | ||
| cellRect.width = (visible - EDGE_OFFSET) * 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a potential issue when the cell is barely visible: visible - EDGE_OFFSET can become negative, leading to negative width values.
I suggest clamping the adjusted value
const visible = cellRect.right - tableRect.left;
const adjusted = Math.max(0, visible - EDGE_OFFSET);
cellRect.width = adjusted * 2;
Fixed positions of plus buttons
Details
Fixed positions of row and column controls
Details
Fixed row dragging
Details