Skip to content
This repository was archived by the owner on Aug 8, 2024. It is now read-only.

fix: table moves up when doing selection #559

Closed
wants to merge 13 commits into from
Closed

fix: table moves up when doing selection #559

wants to merge 13 commits into from

Conversation

LiKang6688
Copy link
Contributor

@LiKang6688 LiKang6688 commented Jun 13, 2022

Head:
when a focused cell is updated, the scroll position is updated accordingly.

Current:
when a focused cell is updated only when using the keyboard to move up, the scroll position is updated accordingly

const bodyCellStyle = useMemo(() => getBodyCellStyle(layout, theme), [layout, theme.name()]);
const hoverEffect = layout.components?.[0]?.content?.hoverEffect;
const cellStyle = { color: bodyCellStyle.color, backgroundColor: theme.table.backgroundColor };
const TableBodyWrapper = forwardRef(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -73,7 +74,7 @@ export default function TableWrapper(props) {
return () => {
memoedWrapper.removeEventListener('focusout', focusOutCallback);
};
}, []);
}, [keyboard]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does keyboard affect the hebaviour of focusout?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, if keyboard.enabled is false it does nothing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good

const memoedContainer = tableBodyWrapperRef.current;
if (!memoedContainer) return () => {};

const keyDownHandler = (evt) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have a quick way to test it, have to leave it.

top: 0,
behavior: 'smooth',
top: Math.max(0, targetOffsetTop),
behavior: 'instant',
Copy link
Contributor Author

@LiKang6688 LiKang6688 Jun 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that instant is more like a native one

@LiKang6688 LiKang6688 requested a review from haxxmaxx June 17, 2022 11:34
@LiKang6688 LiKang6688 removed the request for review from haxxmaxx August 9, 2022 15:02
@LiKang6688 LiKang6688 marked this pull request as draft August 9, 2022 15:02
@LiKang6688 LiKang6688 marked this pull request as ready for review August 9, 2022 15:23
@haxxmaxx
Copy link
Collaborator

I'm looking at the handleNavigateTop code and I don't think we need the tableContainerRef. We already have the rootElement in there and could get the container element from there. Seems like that is enought, don't need the react ref. In that case the listener could be on the body. In fact we already have a onKeyDown there sou should be able to call handleNavigateTop in there

@LiKang6688
Copy link
Contributor Author

I'm looking at the handleNavigateTop code and I don't think we need the tableContainerRef. We already have the rootElement in there and could get the container element from there. Seems like that is enought, don't need the react ref. In that case the listener could be on the body. In fact we already have a onKeyDown there sou should be able to call handleNavigateTop in there

Sounds good. I am looking into it.

@LiKang6688 LiKang6688 marked this pull request as draft August 10, 2022 08:23
@LiKang6688
Copy link
Contributor Author

switch to #627

@LiKang6688 LiKang6688 deleted the fix/scroll branch August 13, 2022 18:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants