dididy commented on code in PR #5057:
URL: https://github.com/apache/zeppelin/pull/5057#discussion_r2322121587


##########
zeppelin-web-angular/src/app/pages/workspace/notebook/notebook.component.ts:
##########
@@ -128,8 +128,15 @@ export class NotebookComponent extends 
MessageListenersManager implements OnInit
       return;
     }
     const definedNote = this.note;
-    definedNote.paragraphs = definedNote.paragraphs.filter(p => p.id !== 
data.id);
-    this.cdr.markForCheck();
+    const paragraphIndex = definedNote.paragraphs.findIndex(p => p.id === 
data.id);
+    definedNote.paragraphs.splice(paragraphIndex, 1);
+
+    setTimeout(() => {
+      const adjustedCursorIndex =
+        paragraphIndex === definedNote.paragraphs.length ? paragraphIndex - 1 
: paragraphIndex + 1;
+      this.listOfNotebookParagraphComponent.find((_, index) => index === 
adjustedCursorIndex)?.focusEditor();
+      this.cdr.markForCheck();
+    }, 250);

Review Comment:
   f49113f
   
   After investigating from multiple angles, I found that when receiving 
`PARAGRAPH_REMOVED` and executing `focusEditor` on the target paragraph, blur 
events such as `onEditorBlur` and `blurEditor` inside the paragraph component 
were being triggered, causing an issue.  
   
   Unlike `ADD_PARAGRAPH`, which works without special handling, this problem 
seems to occur because `nzModalService` is involved.  
   (If `messageService.paragraphRemove` is executed directly inside the 
paragraph component’s `removeParagraph` function without `nzModalService`, the 
issue does not occur)  
   
   Since removing `nzModalService` is not an appropriate solution, I introduced 
an `ignoreBlur` variable to suppress the blur events and re-apply focus as a 
fix.



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

Reply via email to