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

Improve document context handling in ColumnSizing feature #5746

Open
2 tasks done
parassantra opened this issue Sep 16, 2024 · 1 comment
Open
2 tasks done

Improve document context handling in ColumnSizing feature #5746

parassantra opened this issue Sep 16, 2024 · 1 comment

Comments

@parassantra
Copy link

TanStack Table version

v8.20.5

Framework/Library version

v18.2.0

Describe the bug and the steps to reproduce it

Description

The current implementation of the getResizeHandler function in the ColumnSizing feature doesn't properly handle the document context in all scenarios, particularly in environments where the global document object might not be available or when dealing with new windows and React.createPortal.

Proposed Change

typescript:packages/table-core/src/features/ColumnSizing.ts
const contextDocument =
contextDocument ||
(typeof document !== 'undefined'
? (((e as MouseEvent | TouchEvent).target as Element)?.ownerDocument ?? document)
: null)

Expected Behaviour

  • The resize handler should work correctly in various environments, including iframes and server-side rendering scenarios.
  • It should prioritize the explicitly provided document context.
  • It should gracefully handle cases where the global document object is not available.

Current Behaviour

The current implementation may not work correctly in all scenarios, particularly when dealing with windows/iframes or in environments where the global document object is not available.

Steps to Reproduce

  1. Goto https://codesandbox.io/p/sandbox/github/parassantra/react-table-issue
  2. Resize table in parent window it works as expected
  3. Open Popout window also keep main window side by side and resize table.
  4. Mouse events will trigger infinite when mouse moved over parent window.

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

https://codesandbox.io/p/sandbox/github/parassantra/react-table-issue

Screenshots or Videos (Optional)

Screen.Recording.2024-09-15.at.21.40.25.mov

Do you intend to try to help solve this bug with your own PR?

Yes, I am also opening a PR that solves the problem along side this issue

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
@parassantra parassantra changed the title ## Bug Report: Improve document context handling in ColumnSizing feature Improve document context handling in ColumnSizing feature Sep 16, 2024
@parassantra
Copy link
Author

@KevinVandy

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

No branches or pull requests

1 participant