* Override close() to detect unsaved changes and prompt user. * This method is synchronous to match Obsidian's Modal.close() signature.
()
| 274 | * This method is synchronous to match Obsidian's Modal.close() signature. |
| 275 | */ |
| 276 | close(): void { |
| 277 | // If we're already forcing close or showing confirmation, proceed |
| 278 | if (this.pendingClose) { |
| 279 | this.pendingClose = false; |
| 280 | super.close(); |
| 281 | return; |
| 282 | } |
| 283 | |
| 284 | // Prevent re-entrancy if confirmation is already showing |
| 285 | if (this.isShowingConfirmation) { |
| 286 | return; |
| 287 | } |
| 288 | |
| 289 | // Check for unsaved changes |
| 290 | const changes = this.getChanges(); |
| 291 | const hasChanges = Object.keys(changes).length > 0; |
| 292 | |
| 293 | if (!hasChanges) { |
| 294 | // No changes, close immediately |
| 295 | super.close(); |
| 296 | return; |
| 297 | } |
| 298 | |
| 299 | // Show confirmation modal asynchronously |
| 300 | void this.showUnsavedChangesConfirmation(); |
| 301 | } |
| 302 | |
| 303 | /** |
| 304 | * Show confirmation modal for unsaved changes. |
no test coverage detected