diff --git a/CHANGELOG.md b/CHANGELOG.md index de9d83bd..0ddf7a53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ * [UIQM-691](https://issues.folio.org/browse/UIQM-691) Show correct field and toast color when validation returns warnings. * [UIQM-665](https://issues.folio.org/browse/UIQM-665) Fix to generate array content in 008 after changing document type of MARC bib. * [UIQM-694](https://issues.folio.org/browse/UIQM-694) Separate error messages triggered by controlled subfields of different linked fields. +* [UIQM-592](https://issues.folio.org/browse/UIQM-592) Fix to input polish special chars into fields. ## [8.0.1] (https://github.com/folio-org/ui-quick-marc/tree/v8.0.1) (2024-04-18) diff --git a/src/QuickMarcEditor/QuickMarcEditor.js b/src/QuickMarcEditor/QuickMarcEditor.js index a993a2d9..ad6fea44 100644 --- a/src/QuickMarcEditor/QuickMarcEditor.js +++ b/src/QuickMarcEditor/QuickMarcEditor.js @@ -75,6 +75,7 @@ import { updateRecordAtIndex, markLinkedRecords, getLeaderPositions, + isDiacritic, } from './utils'; import css from './QuickMarcEditor.css'; @@ -465,6 +466,8 @@ const QuickMarcEditor = ({ name: 'save', shortcut: 'mod+s', handler: async (e) => { + if (isDiacritic(e.key)) return; + if (!saveFormDisabled) { e.preventDefault(); confirmationChecks.current = { ...REQUIRED_CONFIRMATIONS }; diff --git a/src/QuickMarcEditor/utils.js b/src/QuickMarcEditor/utils.js index e4580cc4..17203580 100644 --- a/src/QuickMarcEditor/utils.js +++ b/src/QuickMarcEditor/utils.js @@ -1220,3 +1220,11 @@ export const isFolioSourceFileNotSelected = ({ selectedSourceFile }) => { export const joinErrors = (errorsA, errorsB) => { return assignWith({}, errorsA, errorsB, (objValue = [], srcValue = []) => objValue.concat(srcValue)); }; + +export const isDiacritic = (char) => { + const specialDiactrics = 'łŁøß'; + + if (specialDiactrics.includes(char)) return true; + + return char.normalize('NFD') !== char; +}; diff --git a/src/QuickMarcEditor/utils.test.js b/src/QuickMarcEditor/utils.test.js index fe86336c..645df136 100644 --- a/src/QuickMarcEditor/utils.test.js +++ b/src/QuickMarcEditor/utils.test.js @@ -1793,4 +1793,22 @@ describe('QuickMarcEditor utils', () => { }); }); }); + + describe('isDiacritic', () => { + it('should all chars to be detected as diacritics', () => { + const diacriticArray = 'ąćęłńóśźżĄĆĘŁŃÓŚŹŻøã鞎šŠşŞß'; + + [...diacriticArray].forEach(c => { + expect(utils.isDiacritic(c)).toBeTruthy(); + }); + }); + + it('should all chars to be detected as not diacritics', () => { + const diacriticArray = 'acelnoszACELNOSZ'; + + [...diacriticArray].forEach(c => { + expect(utils.isDiacritic(c)).toBeFalsy(); + }); + }); + }); });