Skip to content

Commit

Permalink
Reuse the focus editor logic in the page object
Browse files Browse the repository at this point in the history
  • Loading branch information
vivinkrishna-ni committed Oct 4, 2024
1 parent c691f00 commit aed3beb
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,7 @@ export class RichTextEditorPageObject {
.run();
await waitForUpdatesAsync();

if (this.isMentionListboxOpened()) {
this.richTextEditorElement.tiptapEditor.commands.focus();
await waitForUpdatesAsync();
}
await this.focusEditorIfMentionListboxOpened();
}

public async setCursorPosition(position: number): Promise<void> {
Expand Down Expand Up @@ -439,10 +436,7 @@ export class RichTextEditorPageObject {
}

public async clickMentionListboxOption(index: number): Promise<void> {
if (this.isMentionListboxOpened()) {
this.richTextEditorElement.tiptapEditor.commands.focus();
await waitForUpdatesAsync();
}
await this.focusEditorIfMentionListboxOpened();

const listOption = this.getAllListItemsInMentionBox()[index];
listOption?.click();
Expand Down Expand Up @@ -535,4 +529,11 @@ export class RichTextEditorPageObject {
);
return parserMentionConfig;
}

private async focusEditorIfMentionListboxOpened(): Promise<void> {
if (this.isMentionListboxOpened()) {
this.richTextEditorElement.tiptapEditor.commands.focus();
await waitForUpdatesAsync();
}
}
}

0 comments on commit aed3beb

Please sign in to comment.