Skip to content

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

@aurimasy

Description

@aurimasy

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

Activity

BrianHung

BrianHung commented on Jun 1, 2024

@BrianHung
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

BrianHung commented on Jun 1, 2024

@BrianHung
Collaborator

Tell me if #959 works for you.

aurimasy

aurimasy commented on Jun 3, 2024

@aurimasy
Author

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

BrianHung commented on Jun 4, 2024

@BrianHung
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

BrianHung commented on Jun 4, 2024

@BrianHung
Collaborator

added symbols and punctation

aurimasy

aurimasy commented on Jun 5, 2024

@aurimasy
Author

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. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @BrianHung@aurimasy

      Issue actions

        The cell does not enter edit mode if typing a non-English letter · Issue #955 · glideapps/glide-data-grid