dididy commented on PR #5057: URL: https://github.com/apache/zeppelin/pull/5057#issuecomment-3262393224
``` this.nzModalService .confirm({ ... }) .afterClose.pipe(takeUntil(this.destroy$)) .subscribe(() => { // You can execute focus-related events (or other logic) at the point when the modal is closed. }); ``` Other functions that trigger a modal (such as **runAllAbove** and **runAllBelowAndCurrent**) can subscribe to the modal’s close event to execute focus-related logic, and we actually resolved the issue that way before. However, **removeParagraph** is different: it deletes the current paragraph, and we need to set focus on the paragraph that comes after it. If we handled it the same way as the others, we would end up trying to focus a paragraph that has already been deleted (or is about to be). The root cause is that Ant Design’s modal steals focus from Monaco. This creates a timing issue: even if we try to focus the next paragraph after deletion, as long as the modal is not fully destroyed, a blur event will still be triggered. I found in the documentation that there’s an [`nzAutofocus`](https://ng.ant.design/version/9.3.x/components/modal/en#api) option, but this only designates which button in the modal should receive initial focus. Since the paragraph we want to focus isn’t inside the modal, this option isn’t useful (I temporarily set it to `null`, but I’ll remove it if we agree it’s unnecessary). Therefore, the approach I came up with is to wait until the modal is closed and then reapply focus after the last blur event is triggered. 4434380 Previously, I introduced a variable called `ignoreBlur` to work around this. But while looking deeper into the documentation, I discovered that we can check [`nzModalService.openModals.length`](https://ng.ant.design/components/modal/en#related_type_definition) to detect when the modal has closed. So I refactored the code to remove the `ignoreBlur` variable and use this method instead. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: reviews-unsubscr...@zeppelin.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org