mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-26 17:50:38 +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
|
||||
}
|
||||
|
||||
let UID = 0;
|
||||
|
||||
// List of collapsible layer editors
|
||||
class LayerListContainer extends React.Component {
|
||||
static propTypes = {...layerListPropTypes}
|
||||
|
@ -49,6 +51,9 @@ class LayerListContainer extends React.Component {
|
|||
this.state = {
|
||||
collapsedGroups: {},
|
||||
areAllGroupsExpanded: false,
|
||||
keys: {
|
||||
add: UID++,
|
||||
},
|
||||
isOpen: {
|
||||
add: false,
|
||||
}
|
||||
|
@ -57,6 +62,10 @@ class LayerListContainer extends React.Component {
|
|||
|
||||
toggleModal(modalName) {
|
||||
this.setState({
|
||||
keys: {
|
||||
...this.state.keys,
|
||||
[modalName]: UID++,
|
||||
},
|
||||
isOpen: {
|
||||
...this.state.isOpen,
|
||||
[modalName]: !this.state.isOpen[modalName]
|
||||
|
@ -253,6 +262,7 @@ class LayerListContainer extends React.Component {
|
|||
|
||||
return <div className="maputnik-layer-list" ref={this.scrollContainerRef}>
|
||||
<AddModal
|
||||
key={this.state.keys.add}
|
||||
layers={this.props.layers}
|
||||
sources={this.props.sources}
|
||||
isOpen={this.state.isOpen.add}
|
||||
|
|
Loading…
Reference in a new issue