From aed3bebfdfed797926c6814792c79ea2207effbe Mon Sep 17 00:00:00 2001 From: Vivin Krishna <123377523+vivinkrishna-ni@users.noreply.github.com> Date: Fri, 4 Oct 2024 11:38:00 +0530 Subject: [PATCH] Reuse the focus editor logic in the page object --- .../testing/rich-text-editor.pageobject.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/nimble-components/src/rich-text/editor/testing/rich-text-editor.pageobject.ts b/packages/nimble-components/src/rich-text/editor/testing/rich-text-editor.pageobject.ts index 1b6a4a5023..aac0586e3a 100644 --- a/packages/nimble-components/src/rich-text/editor/testing/rich-text-editor.pageobject.ts +++ b/packages/nimble-components/src/rich-text/editor/testing/rich-text-editor.pageobject.ts @@ -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 { @@ -439,10 +436,7 @@ export class RichTextEditorPageObject { } public async clickMentionListboxOption(index: number): Promise { - if (this.isMentionListboxOpened()) { - this.richTextEditorElement.tiptapEditor.commands.focus(); - await waitForUpdatesAsync(); - } + await this.focusEditorIfMentionListboxOpened(); const listOption = this.getAllListItemsInMentionBox()[index]; listOption?.click(); @@ -535,4 +529,11 @@ export class RichTextEditorPageObject { ); return parserMentionConfig; } + + private async focusEditorIfMentionListboxOpened(): Promise { + if (this.isMentionListboxOpened()) { + this.richTextEditorElement.tiptapEditor.commands.focus(); + await waitForUpdatesAsync(); + } + } }