-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Improve contextDocument handling in ColumnSizing feature #5747
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
@KevinVandy Please review when you have time. |
Plus 1 on this. Following for updates |
@KevinVandy Please review this PR. |
Any update on this? |
Also interested in an update |
Please review this PR. |
last time we touched this code, it caused server-side errors when |
@KevinVandy are we required to add a nextjs or remix example with fix in to check this is working? |
@KevinVandy I think we can make use of |
@KevinVandy Please specify what next steps, I should take in order to get this reviewed and merged. |
@KevinVandy @riccardoperra any update on this, this is a critical issue on new windows created through portal. we should merge this fix asap. Please suggest next steps. |
I've been watching this and hoping for the fix to be merged. |
I have not had the chance to make an ssr example to test this |
@KevinVandy I can make this weekend an example maybe using Angular SSR since it's a bit strict about how you use DOM Api (cannot reference document/window directly etc) I never did this as I used React only on browser: could we add some ssr tests using something like renderToString etc? I could invest some time on it EDIT: adding some test cases in table-core package using Node as environment for some test cases may help us to detect some errors |
@KevinVandy after some investigation while debugging with provided example in #5746, I found out that this line may be broken ![]() In fact, even if _contextDocument is provided, it still goes to the next condition, which always returns the main document. We should wrap that condition in parenthesis. _contextDocument || (typeof document !== 'undefined' ? document : null) I think we can move this in an external function in order to do unit testing and be sure to reuse this logic if needed elsewhere A possible fix here: 803ccf9 (just removed jsdom environment in order to run test without polluted globals. Using "typeof" should be safe. By doing this, it's no longer necessary to get the event's ownerDocument, but it might still be useful to have a utility for it. In this case Anyway, @parassantra Your PopupWindow implementation may be revisited since it seems the table created in the window still have a interface PopoutWindowProps {
children: (document: Document) => ReactNode // <-- a signature like exoticComponent / context provider
closeWindow: () => void;
setPopoutDocument: (doc: Document) => void;
width?: number;
height?: number;
}
// then in the return fn
return container && windowDocument // <-- should use some state ref here
? ReactDOM.createPortal(
<>
{children(windowDocument)}
<button onClick={() => popoutWindowRef.current?.close()}>
Close Window
</button>
</>,
container
)
: null;
// outside
<PopupWindow>
{document => (
<ResizableTable popupDocument={document}/>
)}
</PopupWindow> |
@riccardoperra @KevinVandy 1. tried on my local with React [803ccf9] fix(803ccf9) issue is still there see video attached: 803ccf9_not_working.mov2. tried on my local with my proposed fix on React: my_fix_working.mov3. tried on my local with my proposed fix on Next Js: my_fix_next_js.movPlease review on your end. This issue is causing us trouble since a long time. |
@parassantra I forked your example: https://codesandbox.io/p/sandbox/nostalgic-bhaskara-z6n8gf?file=%2Fsrc%2Fcomponents%2FPopoutWidow.tsx%3A19%2C1 using packages from pkg-pr-new (#5989) seems fixing the bug, but as I said I had to refactor PopupWindow |
Oh ok, I got it, I will try with updated code. |
What's this PR
#5746
Enhance the contextDocument assignment logic in the ColumnSizing feature:
This change improves compatibility with different environments and provides
more robust document reference handling for column resizing events.