improve close method

This commit is contained in:
SrGooglo 2023-08-15 18:43:40 +00:00
parent 6b13136fa6
commit b5d529a374

View File

@ -132,8 +132,15 @@ export class Drawer extends React.Component {
return await this.setState({ locked: false })
}
close = () => {
if (this.state.locked) {
close = async ({
unlock = false
} = {}) => {
return new Promise(async (resolve) => {
if (unlock) {
await this.setState({ locked: false })
}
if (this.state.locked && !unlock) {
return console.warn("Cannot close a locked drawer")
}
@ -147,7 +154,10 @@ export class Drawer extends React.Component {
}
this.props.controller.close(this.props.id)
resolve()
}, 500)
})
}
sendEvent = (...context) => {