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

[data grid] Unable to Paste Row Data in Data Grid with CAPS Lock Key Enabled #11790

Closed
dmarciano opened this issue Jan 23, 2024 · 5 comments · Fixed by #11965 or #12121
Closed

[data grid] Unable to Paste Row Data in Data Grid with CAPS Lock Key Enabled #11790

dmarciano opened this issue Jan 23, 2024 · 5 comments · Fixed by #11965 or #12121
Assignees
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Clipboard Related to clipboard copy or paste functionalities

Comments

@dmarciano
Copy link

dmarciano commented Jan 23, 2024

Steps to reproduce

Link to live example: https://mui.com/x/react-data-grid/clipboard/

Steps:

  1. Go to the Clipboard paste section
  2. Copy several columns of data from a spreadsheet (e.g., Excel)
  3. Enable the CAPS lock key
  4. Click on the first cell
  5. Attempt to paste data using CTRL + V

Current behavior

When attempting to paste a row of data with CTRL + V while the CAPS lock key is enabled, nothing will happen. However, if you disable the CAPS lock key, the data will be pasted as expected.

Expected behavior

Row data should be successfully pasted regardless of the status of the CAPS lock key

Context

Trying to allow users to paste rows of data from Excel to a data grid for uploading

Your environment

npx @mui/envinfo
 System:
    OS: Windows 10 10.0.19045
  Binaries:
    Node: 18.18.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.1.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: Not Found
  Browsers:
    Chrome: Version 120.0.6099.225 (Official Build) (64-bit)
    Edge: Version 120.0.2210.144 (Official build) (64-bit)
  npmPackages:
    @emotion/react: ^11.11.0 => 11.11.1
    @emotion/styled: ^11.11.0 => 11.11.0
    @mui/base:  5.0.0-beta.9
    @mui/core-downloads-tracker:  5.14.3
    @mui/icons-material: ^5.8.4 => 5.8.4
    @mui/material: ^5.12.3 => 5.14.3
    @mui/private-theming:  5.13.7
    @mui/styled-engine:  5.13.2
    @mui/styles: ^5.9.3 => 5.9.3
    @mui/system:  5.14.3
    @mui/types:  7.2.4
    @mui/utils:  5.14.3
    @mui/x-data-grid: ^6.3.1 => 6.18.6
    @mui/x-data-grid-premium: ^6.10.2 => 6.18.6
    @mui/x-data-grid-pro:  6.18.6
    @mui/x-date-pickers: ^6.2.1 => 6.2.1
    @mui/x-license-pro:  6.10.2
    @types/react: 18.0.13 => 18.0.13
    react: 18.2.0 => 18.2.0
    react-dom: 18.2.0 => 18.2.0
    typescript: ~4.7.2 => 4.7.4

Search keywords: caps lock, data grid, past

@dmarciano dmarciano added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jan 23, 2024
@zannager zannager added the component: data grid This is the name of the generic UI component, not the React module! label Jan 23, 2024
@michelengelen michelengelen added bug 🐛 Something doesn't work feature: Clipboard Related to clipboard copy or paste functionalities labels Jan 24, 2024
@michelengelen michelengelen changed the title Unable to Paste Row Data in Data Grid with CAPS Lock Key Enabled [data grid] Unable to Paste Row Data in Data Grid with CAPS Lock Key Enabled Jan 24, 2024
@github-project-automation github-project-automation bot moved this to 🆕 Needs refinement in MUI X Data Grid Jan 24, 2024
@michelengelen michelengelen removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jan 24, 2024
@gitstart
Copy link
Contributor

gitstart commented Feb 2, 2024

@michelengelen we would like to pick this up

@shaharyar-shamshi
Copy link
Contributor

@michelengelen I would like to pick up this issue.

after initial checking I found out when caps lock is on CTRL + v becomes CTRL + V

So this

function isPasteShortcut(event: React.KeyboardEvent) {

code will not work as it checking for lowercase v only

corrected version of code will be

const isPasteShortcut = (event: React.KeyboardEvent) => {
  return (
    (event.ctrlKey || event.metaKey) &&
    (event.key.toLowerCase() === 'v' || event.code.toLowerCase() === 'keyv')
  );
};

If you can assign this to me

@romgrk
Copy link
Contributor

romgrk commented Feb 7, 2024

@shaharyar-shamshi You can open a PR with the fix. I would avoid event.code, according to the spec .code represents a physical key, which might not match with the logical key for unusual keyboard layouts.

@shaharyar-shamshi
Copy link
Contributor

@shaharyar-shamshi You can open a PR with the fix. I would avoid event.code, according to the spec .code represents a physical key, which might not match with the logical key for unusual keyboard layouts.

Yes I agree but it is in or condition to be on safer side I included it.

@romgrk
Copy link
Contributor

romgrk commented Feb 7, 2024

But it would be incorrect. E.g. in dvorak layout, the physical V key corresponds to the logical X symbol. So a dvorak user pressing Ctrl + X (in their layout) might have the event.code as KeyV.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module! feature: Clipboard Related to clipboard copy or paste functionalities
Projects
Status: Done
6 participants