mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-16 19:57:52 +01:00
editor: fix scrollLeft value on mobile when using scroll container
This commit is contained in:
@@ -219,6 +219,7 @@ function TableRowToolbar(props: TableToolbarProps) {
|
|||||||
function TableColumnToolbar(props: TableToolbarProps) {
|
function TableColumnToolbar(props: TableToolbarProps) {
|
||||||
const { editor, table } = props;
|
const { editor, table } = props;
|
||||||
const columnToolsRef = useRef<HTMLDivElement>(null);
|
const columnToolsRef = useRef<HTMLDivElement>(null);
|
||||||
|
const isMobile = useIsMobile();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function onSelectionUpdate() {
|
function onSelectionUpdate() {
|
||||||
@@ -245,8 +246,9 @@ function TableColumnToolbar(props: TableToolbarProps) {
|
|||||||
yOffset: 2
|
yOffset: 2
|
||||||
});
|
});
|
||||||
|
|
||||||
const scrollLeft =
|
const scrollLeft = isMobile
|
||||||
table.current?.closest(".simplebar-content-wrapper")?.scrollLeft || 0;
|
? table.current.parentElement?.parentElement?.scrollLeft || 0
|
||||||
|
: table.current?.closest(".simplebar-content-wrapper")?.scrollLeft || 0;
|
||||||
|
|
||||||
columnToolsRef.current.style.left = `${pos.left - scrollLeft}px`;
|
columnToolsRef.current.style.left = `${pos.left - scrollLeft}px`;
|
||||||
columnToolsRef.current.style.top = `${pos.top}px`;
|
columnToolsRef.current.style.top = `${pos.top}px`;
|
||||||
@@ -256,7 +258,7 @@ function TableColumnToolbar(props: TableToolbarProps) {
|
|||||||
return () => {
|
return () => {
|
||||||
editor.off("selectionUpdate", onSelectionUpdate);
|
editor.off("selectionUpdate", onSelectionUpdate);
|
||||||
};
|
};
|
||||||
}, []);
|
}, [isMobile]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex
|
<Flex
|
||||||
|
|||||||
Reference in New Issue
Block a user