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(); + } + } }