Skip to content

Commit dd3ba8d

Browse files
authored
fix: Info panel covers whole sidebar if fewer objects than panels in multi-panel scenario (#3042)
1 parent 6aadff6 commit dd3ba8d

File tree

2 files changed

+45
-12
lines changed

2 files changed

+45
-12
lines changed

src/components/Toolbar/Toolbar.react.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,12 @@ const Toolbar = props => {
177177
{props.isPanelVisible ? (
178178
<>
179179
<Icon width={18} height={18} fill="#797592" name="x-outline" />
180-
Hide Panel
180+
Hide {props.panelCount > 1 ? `${props.panelCount} Panels` : 'Panel'}
181181
</>
182182
) : (
183183
<>
184184
<Icon width={18} height={18} fill="#797592" name="left-outline" />
185-
Show Panel
185+
Show {props.panelCount > 1 ? `${props.panelCount} Panels` : 'Panel'}
186186
</>
187187
)}
188188
</button>

src/dashboard/Data/Browser/DataBrowser.react.js

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -383,15 +383,31 @@ export default class DataBrowser extends React.Component {
383383
}
384384

385385
handleResizeStop(event, { size }) {
386+
// Convert effective width back to full panel width when there are hidden panels
387+
let newPanelWidth = size.width;
388+
if (this.state.panelCount > 1 && this.state.displayedObjectIds.length < this.state.panelCount) {
389+
const actualPanelCount = Math.max(this.state.displayedObjectIds.length, 1);
390+
// Reverse the calculation: fullWidth = (effectiveWidth / actualPanelCount) * panelCount
391+
newPanelWidth = (size.width / actualPanelCount) * this.state.panelCount;
392+
}
393+
386394
this.setState({
387395
isResizing: false,
388-
panelWidth: size.width,
396+
panelWidth: newPanelWidth,
389397
});
390-
window.localStorage?.setItem(AGGREGATION_PANEL_WIDTH, size.width);
398+
window.localStorage?.setItem(AGGREGATION_PANEL_WIDTH, newPanelWidth);
391399
}
392400

393401
handleResizeDiv(event, { size }) {
394-
this.setState({ panelWidth: size.width });
402+
// Convert effective width back to full panel width when there are hidden panels
403+
let newPanelWidth = size.width;
404+
if (this.state.panelCount > 1 && this.state.displayedObjectIds.length < this.state.panelCount) {
405+
const actualPanelCount = Math.max(this.state.displayedObjectIds.length, 1);
406+
// Reverse the calculation: fullWidth = (effectiveWidth / actualPanelCount) * panelCount
407+
newPanelWidth = (size.width / actualPanelCount) * this.state.panelCount;
408+
}
409+
410+
this.setState({ panelWidth: newPanelWidth });
395411
}
396412

397413
setShowAggregatedData(bool) {
@@ -1507,6 +1523,17 @@ export default class DataBrowser extends React.Component {
15071523
...other
15081524
} = this.props;
15091525
const { preventSchemaEdits, applicationId } = app;
1526+
1527+
// Calculate effective panel width based on actual displayed panels
1528+
// When panelCount > 1 but fewer panels are actually displayed, reduce width proportionally
1529+
let effectivePanelWidth = this.state.panelWidth;
1530+
if (this.state.panelCount > 1 && this.state.displayedObjectIds.length < this.state.panelCount) {
1531+
// Width per panel = total width / configured panel count
1532+
// Effective width = width per panel * actual number of displayed panels (or 1 if none)
1533+
const actualPanelCount = Math.max(this.state.displayedObjectIds.length, 1);
1534+
effectivePanelWidth = (this.state.panelWidth / this.state.panelCount) * actualPanelCount;
1535+
}
1536+
15101537
return (
15111538
<div>
15121539
<div>
@@ -1535,7 +1562,7 @@ export default class DataBrowser extends React.Component {
15351562
selectedCells={this.state.selectedCells}
15361563
handleCellClick={this.handleCellClick}
15371564
isPanelVisible={this.state.isPanelVisible}
1538-
panelWidth={this.state.panelWidth}
1565+
panelWidth={effectivePanelWidth}
15391566
isResizing={this.state.isResizing}
15401567
setShowAggregatedData={this.setShowAggregatedData}
15411568
showRowNumber={this.state.showRowNumber}
@@ -1547,7 +1574,7 @@ export default class DataBrowser extends React.Component {
15471574
/>
15481575
{this.state.isPanelVisible && (
15491576
<ResizableBox
1550-
width={this.state.panelWidth}
1577+
width={effectivePanelWidth}
15511578
height={Infinity}
15521579
minConstraints={[100, Infinity]}
15531580
maxConstraints={[this.state.maxWidth, Infinity]}
@@ -1567,18 +1594,24 @@ export default class DataBrowser extends React.Component {
15671594
ref={this.setMultiPanelWrapperRef}
15681595
>
15691596
{(() => {
1570-
// If no objects are displayed, show a single panel with "No object selected"
1597+
// If no objects are displayed, show a single panel
15711598
if (this.state.displayedObjectIds.length === 0) {
1599+
// If there's a selected object, show its data
1600+
const panelData = this.state.selectedObjectId
1601+
? (this.state.multiPanelData[this.state.selectedObjectId] || this.props.AggregationPanelData)
1602+
: {};
1603+
const isLoading = this.state.selectedObjectId && this.props.isLoadingCloudFunction;
1604+
15721605
return (
15731606
<AggregationPanel
1574-
data={{}}
1575-
isLoadingCloudFunction={false}
1607+
data={panelData}
1608+
isLoadingCloudFunction={isLoading}
15761609
showAggregatedData={true}
1577-
errorAggregatedData={{}}
1610+
errorAggregatedData={this.state.selectedObjectId ? this.props.errorAggregatedData : {}}
15781611
showNote={this.props.showNote}
15791612
setErrorAggregatedData={this.props.setErrorAggregatedData}
15801613
setSelectedObjectId={this.setSelectedObjectId}
1581-
selectedObjectId={undefined}
1614+
selectedObjectId={this.state.selectedObjectId}
15821615
appName={this.props.appName}
15831616
className={this.props.className}
15841617
/>

0 commit comments

Comments
 (0)