Skip to content

Commit

Permalink
Merge branch 'main' into users/aagash/editor-globalization-angular-in…
Browse files Browse the repository at this point in the history
…tegration
  • Loading branch information
aagash-ni authored Sep 6, 2023
2 parents 80d5f15 + ff093f4 commit 12b5a33
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 25 deletions.
11 changes: 5 additions & 6 deletions angular-workspace/projects/example-client-app/src/test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files

import 'zone.js';
import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import {
Expand All @@ -19,17 +20,15 @@ getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting(),
{
teardown: { destroyAfterEach: false }
errorOnUnknownElements: true,
errorOnUnknownProperties: true
}
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);

// Workaround to make console.error calls fail tests:
// https://github.com/angular/angular/issues/36430#issuecomment-874772398
// Might be removable after upgrading to Angular 14:
// https://github.com/angular/angular/issues/36430#issuecomment-1117801535
// Elevate console errors to test failures
// eslint-disable-next-line no-console, @typescript-eslint/no-explicit-any
console.error = (data: any): void => fail(data);
console.error = (data: any): void => fail(data);
15 changes: 15 additions & 0 deletions angular-workspace/projects/ni/nimble-angular/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
{
"name": "@ni/nimble-angular",
"entries": [
{
"date": "Wed, 06 Sep 2023 13:58:34 GMT",
"tag": "@ni/nimble-angular_v17.2.1",
"version": "17.2.1",
"comments": {
"none": [
{
"author": "[email protected]",
"package": "@ni/nimble-angular",
"commit": "641593fb78886144aa783c0a54b894a5bdb8a6f2",
"comment": "Align the test.ts configuration"
}
]
}
},
{
"date": "Wed, 06 Sep 2023 05:43:09 GMT",
"tag": "@ni/nimble-angular_v17.2.1",
Expand Down
3 changes: 1 addition & 2 deletions angular-workspace/projects/ni/nimble-angular/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting(),
{
teardown: { destroyAfterEach: false },
errorOnUnknownElements: true,
errorOnUnknownProperties: true
}
Expand All @@ -32,4 +31,4 @@ context.keys().map(context);

// Elevate console errors to test failures
// eslint-disable-next-line no-console, @typescript-eslint/no-explicit-any
console.error = (data: any): void => fail(data);
console.error = (data: any): void => fail(data);
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 12b5a33

Please sign in to comment.