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

The cell does not enter edit mode if typing a non-English letter #955

Closed
aurimasy opened this issue May 27, 2024 · 6 comments · May be fixed by #959
Closed

The cell does not enter edit mode if typing a non-English letter #955

aurimasy opened this issue May 27, 2024 · 6 comments · May be fixed by #959

Comments

@aurimasy
Copy link

Steps to reproduce:

  1. Switch to a non-English language that has some different letters than English (e.g. Lithuanian, German, Russian, etc.).
  2. Open https://grid.glideapps.com/.
  3. Click once on any cell.
  4. Type any non-English letter with a keyboard (e.g. Lithuanian ž, German ö, or Russian ш). The cell does not enter edit mode.
    Typing the letters that are the same as English enters edit mode.

Tested in browsers:
Google Chrome Version 125.0.6422.113 (Official Build) (64-bit)
Firefox 126.0 (64-bit)
OS:
Windows 11 Pro 23H2 22631.3593

@BrianHung
Copy link
Collaborator

Logic for entering edit mode on type is here

if (
editOnType &&
!event.metaKey &&
!event.ctrlKey &&
gridSelection.current !== undefined &&
event.key.length === 1 &&
/[ -~]/g.test(event.key) &&
event.bounds !== undefined &&
isReadWriteCell(getCellContent([col - rowMarkerOffset, Math.max(0, Math.min(row, rows - 1))]))
) {
if (
(!showTrailingBlankRow || row !== rows) &&
(vr.y > row || row > vr.y + vr.height || vr.x > col || col > vr.x + vr.width)
) {
return;
}
reselect(event.bounds, true, event.key);
event.stopPropagation();
event.preventDefault();
}
},

Right now, it checks if the key pressed is a printable character within the ASCII range from space ( ) to tilde (~).

@BrianHung
Copy link
Collaborator

Tell me if #959 works for you.

@aurimasy
Copy link
Author

aurimasy commented Jun 3, 2024

Thank you for your fast response.
It looks like /[\p{L}\p{M}\p{N}]/ug.test(event.key) && works well with non-English letters in Lithuanian, Russian, German. But it misses other symbols such as +, -, !, etc. Maybe better to use /[\p{L}\p{M}\p{N}\p{P}\p{S}]/ug.test(event.key) && in that case?

@BrianHung
Copy link
Collaborator

What symbols are typically shared with the number keys?

The unicode for symbols seems pretty broad:

\p{S} or \p{Symbol}: math symbols, currency signs, dingbats, box-drawing characters, etc.
\p{Sm} or \p{Math_Symbol}: any mathematical symbol.
\p{Sc} or \p{Currency_Symbol}: any currency sign.
\p{Sk} or \p{Modifier_Symbol}: a combining character (mark) as a full character on its own.
\p{So} or \p{Other_Symbol}: various symbols that are not math symbols, currency signs, or combining

@BrianHung
Copy link
Collaborator

added symbols and punctation

@aurimasy
Copy link
Author

aurimasy commented Jun 5, 2024

What symbols are typically shared with the number keys?

The unicode for symbols seems pretty broad:

\p{S} or \p{Symbol}: math symbols, currency signs, dingbats, box-drawing characters, etc.
\p{Sm} or \p{Math_Symbol}: any mathematical symbol.
\p{Sc} or \p{Currency_Symbol}: any currency sign.
\p{Sk} or \p{Modifier_Symbol}: a combining character (mark) as a full character on its own.
\p{So} or \p{Other_Symbol}: various symbols that are not math symbols, currency signs, or combining

I am not sure if \p{Other_Symbol} is really useful, but it is included with \p{S} and this shouldn't be an issue.
Anyway, /[\p{L}\p{M}\p{N}\p{S}\p{P}]/ug.test(event.key) && does all the work. :)

@aurimasy aurimasy closed this as completed Jun 5, 2024
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 a pull request may close this issue.

2 participants