Commit ce97f89d by Marcus Efraimsson

make add panel panel scrollbar adjust when panel/dashboard grid are resized

parent 82054e1a
......@@ -54,6 +54,10 @@ export default class ScrollBar extends React.Component<Props, any> {
return false;
}
update() {
this.scrollbar.update();
}
handleRef = ref => {
this.container = ref;
};
......
......@@ -22,10 +22,13 @@ export interface AddPanelPanelState {
}
export class AddPanelPanel extends React.Component<AddPanelPanelProps, AddPanelPanelState> {
private scrollbar: ScrollBar;
constructor(props) {
super(props);
this.handleCloseAddPanel = this.handleCloseAddPanel.bind(this);
this.renderPanelItem = this.renderPanelItem.bind(this);
this.panelSizeChanged = this.panelSizeChanged.bind(this);
this.state = {
panelPlugins: this.getPanelPlugins(''),
......@@ -35,6 +38,20 @@ export class AddPanelPanel extends React.Component<AddPanelPanelProps, AddPanelP
};
}
componentDidMount() {
this.props.panel.events.on('panel-size-changed', this.panelSizeChanged);
}
componentWillUnmount() {
this.props.panel.events.off('panel-size-changed', this.panelSizeChanged);
}
panelSizeChanged() {
setTimeout(() => {
this.scrollbar.update();
});
}
getPanelPlugins(filter) {
let panels = _.chain(config.panels)
.filter({ hideFromList: false })
......@@ -207,7 +224,7 @@ export class AddPanelPanel extends React.Component<AddPanelPanelProps, AddPanelP
<i className="fa fa-close" />
</button>
</div>
<ScrollBar className="add-panel__items">
<ScrollBar ref={element => (this.scrollbar = element)} className="add-panel__items">
<div className="add-panel__searchbar">
<label className="gf-form gf-form--grow gf-form--has-input-icon">
<input
......
......@@ -140,7 +140,6 @@ export class DashboardGrid extends React.Component<DashboardGridProps, any> {
for (const panel of this.dashboard.panels) {
panel.resizeDone();
}
this.triggerForceUpdate();
}
updateGridPos(item, layout) {
......@@ -153,13 +152,11 @@ export class DashboardGrid extends React.Component<DashboardGridProps, any> {
onResize(layout, oldItem, newItem) {
this.panelMap[newItem.i].updateGridPos(newItem);
this.triggerForceUpdate();
}
onResizeStop(layout, oldItem, newItem) {
this.updateGridPos(newItem, layout);
this.panelMap[newItem.i].resizeDone();
this.triggerForceUpdate();
}
onDragStop(layout, oldItem, newItem) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment