FIREFLY-1954: React Split Pane version upgrade#1977
Conversation
robyww
left a comment
There was a problem hiding this comment.
This looks good. It works in my testing. There are some style things that I don't really understand that I assume is because of the component.
my big question is: why vertical to horizontal ?
| <Stack id='chart-pinned-sideBySide' overflow='hidden' flexGrow={1}> | ||
| <Stack flexGrow={1} position='relative'> | ||
| <SplitPanel split='vertical' defaultSize={400} style={{display: 'inline-flex'}} pKey='chart-sideBySide'> | ||
| <SplitPanel direction='horizontal' defaultSize={400} style={{display: 'inline-flex'}} pKey='chart-sideBySide'> |
There was a problem hiding this comment.
This strikes me as unexpected. did the layout change?
There was a problem hiding this comment.
See below, layout remains the same. Just the meaning of vertical/horizontal is swapped.
|
|
||
| return ( | ||
| <SplitPane split='vertical' defaultSize={200} style={{display: 'inline-flex', ...style}}> | ||
| <SplitPanel direction='horizontal' defaultSize={200} style={{display: 'inline-flex', ...style}} pKey='filter-editor'> |
There was a problem hiding this comment.
again, when did vertical become horizontal
There was a problem hiding this comment.
Yes so this is a big (but easy) change from v0.x to v3.x, they swapped vertical and horizontal to match CSS flex direction. Hence all of these changes.
| } | ||
| setVal(adqlKey, `SELECT TOP 1000 * FROM ${maybeQuote(insertTname,true)}`); | ||
| window.setTimeout( () => prismLiveRef.current.syncStyles?.(), 10); | ||
| window.setTimeout( () => prismLiveRef.current?.syncStyles?.(), 10); |
There was a problem hiding this comment.
You should define a function at the top of the component syncStyles that is
const syncStyles= window.setTimeout( () => prismLiveRef.current?.syncStyles?.(), 10);
loitly
left a comment
There was a problem hiding this comment.
I’ve tested it, and it worked fine. However, I have a suggestion that you should consider.
| <Pane | ||
| key={idx} | ||
| {...paneProps[idx]} | ||
| style={paneStyle} | ||
| > | ||
| {child} | ||
| </Pane> |
There was a problem hiding this comment.
I would expect Pane to be the wrapper used in SplitContent and not injected here. This container should translate the out-dated 'maxSize/minSize' props into minSize defaultSize, than pass-along to the children, which should be Pane since we use SplitContent in all of our split panes.
There was a problem hiding this comment.
+1. This way you won't need to define and maintain paneProps=[{}, {}] dedicatedly here and pass-through props will allow consumers of SplitContent to leverage new/better API of Pane if they decide to.
jaladh-singhal
left a comment
There was a problem hiding this comment.
@kpuriIpac this is thorough! I tested Firefly and spherex primarily and they are working great (and better than before esp since there's no flicker on dragging the split pane resizer).
One minor issue in collapsible panel that appears in SP results: when you collapse it, it's still 2-4px in height as opposed to 0px height on dev. But it's not a dealbreaker since collapsible panel needs work in future anyways to make it handle both vertical and horizontal cases.
| "react-router-dom": "^6.14.0", | ||
| "react-slick": "~0.31", | ||
| "react-split-pane": "~0.1", | ||
| "react-split-pane": "^3.2.0", |
There was a problem hiding this comment.
We generally pin the minor version too since some packages introduce breaking change in minor version too (not sure about react-split-pane, looks stable enough) and hence use ~ instead of ^. We had a long discussion over this last time I had to update package.json 😅 and I added that to our dev documentation.
| const textArea = adqlEl.current?.querySelector('textarea'); | ||
| // adopt textArea | ||
| prismLiveRef.current = new Prism.Live(textArea); | ||
| let cancelled = false; |
There was a problem hiding this comment.
Might be worth abstracting this out as a hook since above useEffect follows same pattern and it obscures the two-line business logic.
| <Pane | ||
| key={idx} | ||
| {...paneProps[idx]} | ||
| style={paneStyle} | ||
| > | ||
| {child} | ||
| </Pane> |
There was a problem hiding this comment.
+1. This way you won't need to define and maintain paneProps=[{}, {}] dedicatedly here and pass-through props will allow consumers of SplitContent to leverage new/better API of Pane if they decide to.
| function CollapsibleSplitContent({sx={}, panelTitle, children, ...props}) { | ||
| const {isOpen, onToggle} = useContext(SplitContext); | ||
|
|
||
| // TODO: dynamically calculate styles based on the position of toggle button and split direction (passed as props) |
There was a problem hiding this comment.
This is an important TODO that I'd advise against removing since this component isn't mature enough to handle both vertical and horizontal splits. If you want to remove it, we should at least add this note to docstring of this component and mark it @experimental
| onDragStarted: () => setIsSplitterDragging(true), | ||
| onDragFinished: (currentSize) => { | ||
| setIsSplitterDragging(false); | ||
| setIsCollapsibleOpen(currentSize > collapsedSize); // update the open state after dragging |
There was a problem hiding this comment.
again these code comments (and below) were helpful to understand the complex layout manipulation code.
Ticket: FIREFLY-1954
IFE PR: https://github.com/IPAC-SW/irsa-ife/pull/472
v0.1.92tov3.2.0DockLayoutPanel. v0 allowed sizing props to be applied at the parentSplitPanelevel, but v3 moves that to the individualPanecomponents.SplitPane(usingreact-split-panedirectly) to use ourSplitPanelwrapper insteadAdvancedADQLandTabPanelinclude timing fixes for react-split-pane's v3 onwards ResizeObserver-based layoutAdvancedADQLin particular, earlier the code assumed DOM was present when the useEffect forPrism.highlighAllran), but with v3.2.0 of react-split-pane using ResizeObserver for layout measurements, I noticed the Pane content can become available after the useEffect where we try to initializePrismdockerfilechange to Node 20 from Node 18 was needed becausereact-split-pane@3.2.0declaresnode >= 20and my Jenkins builds were failing without this change. I will talk to @loitly about this before deciding if we need to keep this.Testing:
Firefly, Euclid, Spherex, Timeseries