Fixing multiple selected panel in settings

This commit is contained in:
Jean Ouina 2020-06-11 18:39:32 +02:00
parent 09127bbeeb
commit c93db10e6e
5 changed files with 42 additions and 11 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -7,6 +7,7 @@
"build": "webpack --progress --colors",
"watch": "webpack --progress --colors --watch",
"build-prod": "webpack --progress --colors --mode production -o js/main.min.js --devtool none",
"watch-prod": "webpack --progress --colors --watch --mode production -o js/main.min.js --devtool none",
"test": "echo \"Error: no test specified\" && exit 1",
"minify": "gulp minify-js && gulp minify-css",
"minify-js": "gulp minify-js",

View File

@ -9,9 +9,8 @@ import TooltipWrap from "../ui/tooltipWrap";
export default class V2_SettingsPanel_Sidebar {
constructor(onClick, onClickLightcord) {
constructor(onClick) {
this.onClick = onClick;
this.onClickLightcord = onClickLightcord
}
get items() {

View File

@ -24,6 +24,8 @@ export default class V2C_SideBar extends BDV2.reactComponent {
this.setInitialState();
this.onClick = this.onClick.bind(this);
this.setSelected = this.setSelected.bind(this);
sidebars.push(this)
}
setInitialState() {
@ -69,9 +71,25 @@ export default class V2C_SideBar extends BDV2.reactComponent {
si.className = this.nscn;
}
this.setState({selected: null});
setUnselected()
this.setState({selected: id});
if (this.props.onClick) this.props.onClick(id);
}
componentWillUnmount(){
let sidebarIndex = sidebars.findIndex(e => e === this)
if(sidebarIndex)sidebars.splice(sidebarIndex, 1)
}
}
const sidebars = []
export function setUnselected(){
sidebars.forEach((sidebar) => {
if(!sidebar.state.selected)return
sidebar.setState({
selected: null
})
})
}