fix(va): guard deferred contextMenu toggle against destroyed instance
This commit is contained in:
@@ -2196,29 +2196,38 @@ export class EditorComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
toggleHotPlugin(pluginName: string, enable: boolean) {
|
||||
const hot = this.hotInstance
|
||||
|
||||
hot.batch(() => {
|
||||
const contextMenuPlugin = hot.getPlugin<any>(pluginName)
|
||||
const contextMenuPlugin = hot.getPlugin<any>(pluginName)
|
||||
|
||||
if (!contextMenuPlugin) {
|
||||
console.warn(
|
||||
'Toggle Hot Plugin failed - Plugin named: ' +
|
||||
pluginName +
|
||||
' - could not be found.'
|
||||
)
|
||||
if (!contextMenuPlugin) {
|
||||
console.warn(
|
||||
'Toggle Hot Plugin failed - Plugin named: ' +
|
||||
pluginName +
|
||||
' - could not be found.'
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
// The instance may be destroyed/rebuilt within this 100ms window (e.g. a
|
||||
// VA filter reload repopulates the grid). A destroyed plugin has its `hot`
|
||||
// reference deleted, so enablePlugin()/disablePlugin() would throw on
|
||||
// `this.hot.getSettings()`. Bail if the instance is gone or was swapped.
|
||||
if (
|
||||
hot.isDestroyed ||
|
||||
this.hotInstance !== hot ||
|
||||
!contextMenuPlugin.hot
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
if (enable) {
|
||||
contextMenuPlugin.enablePlugin()
|
||||
return
|
||||
}
|
||||
|
||||
if (enable) {
|
||||
contextMenuPlugin.enablePlugin()
|
||||
} else {
|
||||
contextMenuPlugin.disablePlugin()
|
||||
}, 100)
|
||||
}
|
||||
|
||||
hot.render()
|
||||
})
|
||||
}, 100)
|
||||
}
|
||||
|
||||
private dynamicCellValidationDisabled(row: number, col: number) {
|
||||
|
||||
Reference in New Issue
Block a user