Skip to content

Commit

Permalink
Rich Text Editor | Revert Firefox workaround for caret disappearing i…
Browse files Browse the repository at this point in the history
…ssue (#1482)

# Pull Request

## 🤨 Rationale

Issue Link : #1454

Reverting the workaround made for the above issue of blinking Caret
disappeared when clicking on the formatting button in Firefox, As it is
fixed with the latest release of Firefox browser
([v117](https://www.mozilla.org/en-US/firefox/117.0/releasenotes/)).

## 👩‍💻 Implementation

Removed `forceFocusEditor()` function on button interaction handlers.

## 🧪 Testing

- Manually tested the behavior by installing the latest Firefox browser
(v117) and comparing the behaviors with previous versions (v116 and
before).
Firefox behaviour test link:
https://bug1496769.bmoattachments.org/attachment.cgi?id=9014846, Please
use this to verify in
different versions of Firefox. (Note: The above link doesn't seem like
works with NI VPN)

## ✅ Checklist

<!--- Review the list and put an x in the boxes that apply or ~~strike
through~~ around items that don't (along with an explanation). -->

- [x] I have updated the project documentation to reflect my changes or
determined no changes are needed.
  • Loading branch information
aagash-ni authored Sep 6, 2023
1 parent 8ec09f7 commit ff093f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Revert firefox workaround for caret disappear",
"packageName": "@ni/nimble-components",
"email": "[email protected]",
"dependentChangeType": "patch"
}
17 changes: 0 additions & 17 deletions packages/nimble-components/src/rich-text-editor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ export class RichTextEditor extends FoundationElement implements ErrorPattern {
*/
public boldButtonClick(): void {
this.tiptapEditor.chain().focus().toggleBold().run();
this.forceFocusEditor();
}

/**
Expand All @@ -237,7 +236,6 @@ export class RichTextEditor extends FoundationElement implements ErrorPattern {
public boldButtonKeyDown(event: KeyboardEvent): boolean {
if (this.keyActivatesButton(event)) {
this.tiptapEditor.chain().focus().toggleBold().run();
this.forceFocusEditor();
return false;
}
return true;
Expand All @@ -249,7 +247,6 @@ export class RichTextEditor extends FoundationElement implements ErrorPattern {
*/
public italicsButtonClick(): void {
this.tiptapEditor.chain().focus().toggleItalic().run();
this.forceFocusEditor();
}

/**
Expand All @@ -259,7 +256,6 @@ export class RichTextEditor extends FoundationElement implements ErrorPattern {
public italicsButtonKeyDown(event: KeyboardEvent): boolean {
if (this.keyActivatesButton(event)) {
this.tiptapEditor.chain().focus().toggleItalic().run();
this.forceFocusEditor();
return false;
}
return true;
Expand All @@ -271,7 +267,6 @@ export class RichTextEditor extends FoundationElement implements ErrorPattern {
*/
public bulletListButtonClick(): void {
this.tiptapEditor.chain().focus().toggleBulletList().run();
this.forceFocusEditor();
}

/**
Expand All @@ -281,7 +276,6 @@ export class RichTextEditor extends FoundationElement implements ErrorPattern {
public bulletListButtonKeyDown(event: KeyboardEvent): boolean {
if (this.keyActivatesButton(event)) {
this.tiptapEditor.chain().focus().toggleBulletList().run();
this.forceFocusEditor();
return false;
}
return true;
Expand All @@ -293,7 +287,6 @@ export class RichTextEditor extends FoundationElement implements ErrorPattern {
*/
public numberedListButtonClick(): void {
this.tiptapEditor.chain().focus().toggleOrderedList().run();
this.forceFocusEditor();
}

/**
Expand All @@ -303,7 +296,6 @@ export class RichTextEditor extends FoundationElement implements ErrorPattern {
public numberedListButtonKeyDown(event: KeyboardEvent): boolean {
if (this.keyActivatesButton(event)) {
this.tiptapEditor.chain().focus().toggleOrderedList().run();
this.forceFocusEditor();
return false;
}
return true;
Expand Down Expand Up @@ -566,15 +558,6 @@ export class RichTextEditor extends FoundationElement implements ErrorPattern {
}
});
}

// In Firefox browser, once the editor gets focused, the blinking caret will be visible until we click format buttons (Bold, Italic ...) in the Firefox browser (changing focus).
// But once any of the toolbar button is clicked, editor internally has its focus but the blinking caret disappears.
// As a workaround, manually triggering blur and setting focus on editor makes the blinking caret to re-appear.
// Mozilla issue https://bugzilla.mozilla.org/show_bug.cgi?id=1496769 tracks removal of this workaround.
private forceFocusEditor(): void {
this.tiptapEditor.commands.blur();
this.tiptapEditor.commands.focus();
}
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
Expand Down

0 comments on commit ff093f4

Please sign in to comment.