react-data-grid
react-data-grid copied to clipboard
Add top and left to cell editor props back
Use case
The top and left properties were removed (PR #2420) from CellEditorProps which is taking away an important functionality to have custom editor with portal rendered at the cell position. We want to have a custom editor that opens at (right below) the cell position. The top and left properties are useful in positioning the cell editor at desired location when editor is rendered with portal and possibly floating on/below the cell itself.
Proposed solution
- Add top and left back to CellEditorProps. OR
- When creating editor with portal, use current cell as the portal target (instead of Body) if user does not provide their custom portal target.
@amanmahajan7 I want to check if there is any plan for this or I can help make this change and raise a PR or do you have something else in mind for Editors for future?
@chirayuchiripal can you provide us more info on the editor that needs the dimensions? If you are using something like a custom dropdown then can you render the input in the cell and the menu in a portal?
@amanmahajan7 When we render the custom dropdown in portal, we need to position it below the cell. I couldn't find a way to do that without knowing the top and left attribute of the current cell which is no longer available. Is there any way to calculate it from the given EditorProps?
Internally we use react-popper to display things like dropdown selects or autocompleters, I highly recommend it: https://popper.js.org/react-popper/ https://github.com/popperjs/react-popper
@nstepien I am aware of that library. This not about which library to use for rendering in portal. It is about editor portal target and positioning that with respect to cell position. If I have to ask it differently, is there an example in the demo website where you use a custom editor rendered in portal which is positioned below the cell being edited?
Something like this: https://pasteboard.co/AlqGl16ibgPR.png
I have this same problem. I'm using Popper, but I want the popup to be positioned at the selected cell, not centered in the document body. AFAIK, popper just needs an anchorEl
. It seems like it would be easy to pass the selected cell element via the EditorProps
?