mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
make add panel panel scrollbar adjust when panel/dashboard grid are resized
This commit is contained in:
parent
82054e1a3e
commit
ce97f89de6
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user