mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 02:05:25 +01:00
Don't remember state when toggling <AddModal/>
This commit is contained in:
parent
0aa629164a
commit
5448cdbe4e
1 changed files with 10 additions and 0 deletions
|
@ -35,6 +35,8 @@ function findClosestCommonPrefix(layers, idx) {
|
||||||
return closestIdx
|
return closestIdx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let UID = 0;
|
||||||
|
|
||||||
// List of collapsible layer editors
|
// List of collapsible layer editors
|
||||||
class LayerListContainer extends React.Component {
|
class LayerListContainer extends React.Component {
|
||||||
static propTypes = {...layerListPropTypes}
|
static propTypes = {...layerListPropTypes}
|
||||||
|
@ -49,6 +51,9 @@ class LayerListContainer extends React.Component {
|
||||||
this.state = {
|
this.state = {
|
||||||
collapsedGroups: {},
|
collapsedGroups: {},
|
||||||
areAllGroupsExpanded: false,
|
areAllGroupsExpanded: false,
|
||||||
|
keys: {
|
||||||
|
add: UID++,
|
||||||
|
},
|
||||||
isOpen: {
|
isOpen: {
|
||||||
add: false,
|
add: false,
|
||||||
}
|
}
|
||||||
|
@ -57,6 +62,10 @@ class LayerListContainer extends React.Component {
|
||||||
|
|
||||||
toggleModal(modalName) {
|
toggleModal(modalName) {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
keys: {
|
||||||
|
...this.state.keys,
|
||||||
|
[modalName]: UID++,
|
||||||
|
},
|
||||||
isOpen: {
|
isOpen: {
|
||||||
...this.state.isOpen,
|
...this.state.isOpen,
|
||||||
[modalName]: !this.state.isOpen[modalName]
|
[modalName]: !this.state.isOpen[modalName]
|
||||||
|
@ -253,6 +262,7 @@ class LayerListContainer extends React.Component {
|
||||||
|
|
||||||
return <div className="maputnik-layer-list" ref={this.scrollContainerRef}>
|
return <div className="maputnik-layer-list" ref={this.scrollContainerRef}>
|
||||||
<AddModal
|
<AddModal
|
||||||
|
key={this.state.keys.add}
|
||||||
layers={this.props.layers}
|
layers={this.props.layers}
|
||||||
sources={this.props.sources}
|
sources={this.props.sources}
|
||||||
isOpen={this.state.isOpen.add}
|
isOpen={this.state.isOpen.add}
|
||||||
|
|
Loading…
Reference in a new issue