diff --git a/app/components/ui/font-picker.ts b/app/components/ui/font-picker.ts index e15cf01..0935ca3 100644 --- a/app/components/ui/font-picker.ts +++ b/app/components/ui/font-picker.ts @@ -62,6 +62,18 @@ export default class UiFontPicker extends Component { @action onFontNameChange(e: CustomEvent) { const fontName = (e.target as CalciteCombobox).value as string; + // This is not supposed to happen (aka. not initiate by "calcite-combobox") + // this happens when `fontName` change from outside of font-picker & actual filter are no longer returning a list containing `fontName` + if (!fontName) { + // Reset font-picker to current font + const currentFont = this.fontManager.fontList.get(this.args.fontName); + if (currentFont) { + this.fontCategory = currentFont.category; + this.fontScript = undefined; + return; + } + } + const font = this.fontManager.fontList.get(fontName); if (font) { this.args.onFontSettingsChange(fontName, font.variants[0]); diff --git a/tests/unit/services/font-manager-test.ts b/tests/unit/services/font-manager-test.ts index f0b1a55..77e6c69 100644 --- a/tests/unit/services/font-manager-test.ts +++ b/tests/unit/services/font-manager-test.ts @@ -3,7 +3,7 @@ import { setupTest } from 'ember-qunit'; import * as opentype from 'opentype.js'; import cases from 'qunit-parameterize'; import type FontManagerService from 'text2stl/services/font-manager'; -import type { Variant } from '@samuelmeuli/font-manager'; +import type { Variant } from 'text2stl/services/font-manager'; const mockedFontList = new Map();