Don't remember state when toggling <AddModal/>

This commit is contained in:
orangemug 2020-05-21 10:07:22 +01:00
parent 0aa629164a
commit 5448cdbe4e

View file

@ -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}