Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIQM-592 Fix input polish chars into fields #726

Merged
merged 3 commits into from
Sep 18, 2024
Merged

Conversation

przemyslawturek
Copy link
Contributor

Purpose

Problem detected only on windows with polish programmer keyboard installed (default for polish).
No issue detected on Mac or Linux.
Prevent execute action for ex. "Save record" triggered from shortcut ctrl + s when inputing polish special chars ś or Ś.

Approach

Detects pressing the ctrl and alt keys and interrupts shortcut actions.

Issues

UIQM-592

ScreenRecords

Before changes

Before_UIQM-592.mp4

After changes

After_UIQM-592.mp4

On Windows fix by prevent action Save record with shortcut ctrl + s when input ś or Ś into text field
Copy link

github-actions bot commented Sep 17, 2024

Jest Unit Test Statistics

    1 files  ±0    47 suites  ±0   2m 58s ⏱️ -7s
466 tests +2  466 ✔️ +2  0 💤 ±0  0 ±0 
469 runs  +2  469 ✔️ +2  0 💤 ±0  0 ±0 

Results for commit 6234e88. ± Comparison against base commit 42dfeef.

♻️ This comment has been updated with latest results.

@@ -465,6 +465,10 @@ const QuickMarcEditor = ({
name: 'save',
shortcut: 'mod+s',
handler: async (e) => {
if (['ctrl', 'alt'].every(x => e.pressedKeys.includes(x))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@przemyslawturek please add a comment explaining that ctrl+alt+S is a combination for Ś, so to prevent the saving we need to check for this combination

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will block all ctrl+alt+... key combinations. Maybe this will fix the issue:

function isPolishDiacritic(char) {
  const polishDiacriticRegex = /[ąćęłńóśźżĄĆĘŁŃÓŚŹŻ]/;
  return polishDiacriticRegex.test(char);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another way is to check if the character is a diacritical character and if so, prevent the action.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think to detect diacritical characters is more universal for other languages

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be worth revising this approach too folio-org/ui-inventory#2350.

Added utils function to detect diacritics chars - polish, romanian, czech etc.
In polish ł, Ł chars is special diactritics that is not normalized char to l, L.
Copy link

@przemyslawturek przemyslawturek merged commit 0e3356c into master Sep 18, 2024
5 checks passed
@przemyslawturek przemyslawturek deleted the UIQM-592 branch September 18, 2024 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants