Firefly-1451: Embedded Position Search Panel Enhancements#1548
Conversation
| header: oneOfType([string, func, element]), | ||
| expandedHeader: oneOfType([string, func, element]), |
There was a problem hiding this comment.
Instead of adding new prop and slotProps, I suggest fixing the header prop so that it does what it was designed to do. header should be:
header: oneOfType([node, func]), // func is called with isOpen as a parametere227013 to
ff63cad
Compare
robyww
left a comment
There was a problem hiding this comment.
This is looking good. The only thing I see now is making the header small when the panel is opened.
ff63cad to
f61b9e2
Compare
| <CollapsibleGroup | ||
| sx={{borderWidth: '0px', | ||
| '& .MuiAccordionSummary-root': { | ||
| paddingBlockStart: '0.5rem', | ||
| paddingBlockEnd: '0.5rem', | ||
| minBlockSize: '1rem', | ||
| '&.Mui-expanded': { | ||
| height: '1rem ' | ||
| } | ||
| }}}> |
There was a problem hiding this comment.
@loitly do you mind reviewing this latest commit? it controls the styling for the header when the search panel is open (the idea was to make it as small as possible, as the scientists don't want the search panel to take up too much space) but still keep it collapsible.
Feel free to review other stuff too, but if this looks ok I can go ahead and merge this PR. Here's the test build: https://firefly-1451-embed-panel-enhanced.irsakudev.ipac.caltech.edu/applications/euclid
| {title && <><Typography color={'warning'} level='title'>{title}</Typography></>} | ||
| <Typography color={'neutral'} level='body-md'> | ||
| <Typography component='span' color={'primary'}>Search Type</Typography>: {searchType} | ||
| {showRadius && searchType === 'Cone' && <> | ||
| , <Typography component='span' color={'primary'}>Search Radius</Typography>: {radius} | ||
| </>} |
There was a problem hiding this comment.
The combination of <></>, , and nested Typography is hard to look at. It would make it a lot easier to read if you define a simple function so you don't repeat yourself.
const keyVal = (k,v) => <>, <Typography component='span' color={'primary'}>{k}</Typography>: {v}</>;I don't think component='span' is needed, but I guess you did it for a reason.
| const searchType = doGetConeAreaOp() === CONE_CHOICE_KEY ? 'Cone' : (doGetConeAreaOp() === POLY_CHOICE_KEY ? 'Polygon' : 'Multi-Object'); | ||
| const coords = searchType === 'Cone' ? (reqObj?.UserTargetWorldPt || reqObj?.circleTarget) : (reqObj?.Polygon || reqObj?.['POS-polygon']); | ||
| const radius = reqObj?.radius || reqObj?.circleSize; | ||
|
|
||
| //in case of Multi-Object, get the fileName & rows | ||
| const fileName = searchType === 'Multi-Object' ? reqObj?.uploadInfo?.fileName : undefined; | ||
| const rows = searchType === 'Multi-Object' ? reqObj?.uploadInfo?.totalRows : undefined; | ||
|
|
||
| const defSlotProps = { | ||
| searchSummary: { | ||
| title: undefined, | ||
| searchType, coords, radius, fileName, rows, | ||
| showCoords: false, | ||
| showRadius: false, | ||
| showFileInfo: false, | ||
| sx:{} | ||
| }, |
There was a problem hiding this comment.
I would not have put these logic here. These logic should be in SearchSummary instead.
Also, why would you need all of these props?
searchType, coords, radius, fileName, rows are calculated. When would you ever want to override it?
showCoords, showRadius, showFileInfo props are contingent on whether or not there's value in coords, radius, fileName. Why would you need flags?
There was a problem hiding this comment.
About this, you're right about the first part. I need not add searchType, coords, radius, fileName, rows to searchSummary/defSlotProps as these are not meant to be overridden. So I'll just pass these directly to SearchSummary.
As for the second part, @robyww wanted the Search Summary to be customizable by whoever's calling it (for example: see how I'm calling it for Euclid here: https://github.com/IPAC-SW/irsa-ife/pull/323/files). DCE may want to call it differently, and for instance, may not want to show radius even when it's available. In fact, even though title does take up extra space, it can optionally be left empty as well.
That was the idea behind keeping the Search Summary customizable by any component calling EmbeddedPositionSearchPanel... But I am open to better ideas (or even a better default). Right now the default is to just show the Search Type (Cone/Polygon/Multi-object) and nothing else. And I can get rid of the title option altogether if it seems like there would be no good use case for it.
| direction={'row'} | ||
| width={'100%'} | ||
| slotProps={{ | ||
| searchBar: {px:0, py:0, justifyContent: 'left'}, |
| else setIsHovered(true); | ||
| }} | ||
| style={{display: 'flex', flexDirection: 'column', alignItems: 'center', alignSelf: 'stretch', height:'100%', | ||
| paddingBottom:insetSpacial?0:20, position: 'relative'}}> |
| <CollapsibleGroup | ||
| sx={{borderWidth: '0px', |
There was a problem hiding this comment.
CollapsibleGroup uses variant='outlined' by default. To remove border, you should set a different value, like variant='plain'.
| '& .MuiAccordionSummary-root': { | ||
| paddingBlockStart: '0.5rem', | ||
| paddingBlockEnd: '0.5rem', | ||
| minBlockSize: '1rem', | ||
| '&.Mui-expanded': { | ||
| height: '1rem ' | ||
| } |
There was a problem hiding this comment.
I don't think these add any value except for additional padding which, in my opinion, is not needed. It however makes it really hard for someone else to modify months from now.
There was a problem hiding this comment.
Okay so the reasoning behind this one is interesting. From what I can tell Joy/MUI's AccordionSummary assigns the following values:
paddingBlockStart: var(--ListItem-paddingY)
paddingBlockEnd: var(--ListItem-paddingY)
minBlockSize: var(--ListItem-minHeight)
which are inherited from the default JoyAccordionGroup as:
--ListItem-minHeight: 2.25rem;
--ListItem-paddingY: 0.25rem;
--ListItem-paddingX: 0.75rem;
Now I could potentially set these in ThemeSetup.js if we wanted to use these values (the ones I overrode) elsewhere too, but it actually looks good in other places, for example this one from Firefly Image tab (ImageSelect.jsx).
Now the same (without me overriding the values) looks like this on Euclid (compare it with the test build):
which @robyww mentioned makes the header too big when the search panel is open.
So in order to make it smaller, I added this extra bit of styling. It's possible there may be simpler way to set the height, but I tried a few things and unless I overrode (or unchecked) this default style, my desired height for the header/summary was not respected.
Anyway, if we decide to keep this, I can add a small comment explaining this choice for future developer to understand at first glance.
Oh yes that's a bug, thanks for pointing it out. the Header component does not rerender unless you do a mouse over (and then it updates the coordinates). The padding between Coordinates and Search button is because |
6520a59 to
2c426c1
Compare
|
@loitly I addressed most of your feedback in the latest commit.
Test builds: Euclid & DCE (DCE is mostly to make sure the panel looks okay when expanded in DCE, it'll be empty when collapsed except for |
loitly
left a comment
There was a problem hiding this comment.
I confirm coordinates are updating while in collapsed mode now. Ok to merge.
| {keyValuePairs.map((pair, index) => | ||
| keyVal(pair.k, pair.v, index === keyValuePairs.length - 1) | ||
| )} |
There was a problem hiding this comment.
I think you misunderstood. Now, it looks worse than before. What I meant is this,
{ keyVal('Search Type', searchType) }
{ showRadius && searchType === 'Cone' && keyVal('Search Radius', radius) }
{ showCoords && searchType !== 'Multi-Object' && coords && keyVal('Coordinates', coords) }If you want to insert a , in between, add a <Stack divider={', '} direction='row'> around them. Of course, your keyVal function have to return an element and not fragment for this to work.
This is only to give you an idea of how it could have been done. As long as it's working for you, I am ok you leaving it as is.
There was a problem hiding this comment.
Yeah this makes sense and the code is definitely cleaner using this suggested approach, but even after setting direction='row' for the divider stack, the formatting still looks kind of weird (I can add a screenshot if you'd like to take a look), so I'll leave this as is.
| <Slot component={SearchSummary} {...defSlotProps.searchSummary} searchType={searchType} | ||
| coords={coords} radius={radius} fileName={fileName} | ||
| rows={rows} slotProps={slotProps?.searchSummary}/> |
There was a problem hiding this comment.
This is exactly the same as when you left them in defSlotProps. Why move them out here?
| if (!isSearchPanel) setIsHovered(false); | ||
| else setIsHovered(true); |
There was a problem hiding this comment.
Isn't this setIsHovered(isSearchPanel); ?
There was a problem hiding this comment.
Yes you're right, I can make it simpler, it would be setIsHovered(isSearchPanel) (whatever the value of isSearchPanel is)
|
@robyww (For Monday May 13 - I'll ping you on Slack on Monday):
Note: Region Explorer's Search Panel looks a little too wide, this is due to a change in |
| const Header = function(isOpen) { | ||
| const {groupKey} = useContext(FieldGroupCtx); | ||
| const reqObj = getFieldGroupResults(groupKey,true); |
There was a problem hiding this comment.
@loitly I think I get what you were trying to say earlier - instead of sending
searchType, coords, radius, fileName, rows to SearchSummary component, I could just send/use this request object directly in SearchSummary? is that right?
| const [getTargetWp,]= useFieldGroupValue(targetKey); | ||
| const [getHiPSRadius,]= useFieldGroupValue(sizeKey); | ||
| const [getPolygon,]= useFieldGroupValue(polygonKey); | ||
|
|
||
| const userEnterWorldPt= () => parseWorldPt(getTargetWp()); | ||
| const worldPt = formatWorldPtToString(userEnterWorldPt()); | ||
|
|
||
| const searchType = doGetConeAreaOp() === CONE_CHOICE_KEY ? 'Cone' : (doGetConeAreaOp() === POLY_CHOICE_KEY ? 'Polygon' : 'Multi-Object'); | ||
| const coords = searchType === 'Cone' ? worldPt : getPolygon(); | ||
| const radius = getHiPSRadius(); | ||
|
|
||
| //in case of Multi-Object, get the fileName & rows | ||
| const fileName = searchType === 'Multi-Object' ? reqObj?.uploadInfo?.fileName : undefined; | ||
| const rows = searchType === 'Multi-Object' ? reqObj?.uploadInfo?.totalRows : undefined; | ||
|
|
||
| const defSlotProps = { | ||
| searchSummary: { | ||
| title: undefined, | ||
| showCoords: false, | ||
| showRadius: false, | ||
| showFileInfo: false, | ||
| searchType, coords, radius, fileName, rows, | ||
| sx:{} | ||
| }, | ||
| }; |
There was a problem hiding this comment.
All this work should be done in SearchSummary
- for force a rerender use:
useFieldGroupRerender([targetKey,sizeKey,polygonKey,CONE_AREA_KEY]);SearchSummary should only take a request
<Slot component={SearchSummary} request={reqObj}/>-
SearchSummaryis just a default implementation that will probably always be replaced. We may may need to make a helper components for replacing it but that will be in future steps. -
SearchSummary's job is to take a request object and make the header UI.
robyww
left a comment
There was a problem hiding this comment.
Header and SearchSummary should be declared outside of the EmbeddedPositionSearchPanel. Move those out and then it will be fine to merge.
…ch summary and opacity
ba74da4 to
7765ab5
Compare



FIREFLY-1451:
see ticket details
made header as small as possible when search panel is open, and when collapsed, display a search summary.
reduced opacity of search panel on mouse click anywhere outside the search panel, but hover/mouseover the search panel brings it back to 100% opacity
corresponding irsa-ife PR: https://github.com/IPAC-SW/irsa-ife/pull/323
Testing:
EmbeddedPositionSearchPanelEmbeddedPositionSearchPanelin a FieldGroup with a groupKey, then this may work as well (or if we decide not to make it collapsible for DCE, then the collapse behavior can be made conditional inEmbeddedPositionSearchPanel).