Material-table: Option to turn off committing edits when Enter key pressed

Created on 25 Aug 2020  路  3Comments  路  Source: mbrn/material-table

When editing a row, when the Enter key is pressed, the edit is committed. If the editor is a multi-line editor, e.g. for rich text, this leaves no way to add new lines in the text. It would be nice to have an option to disable commit-on-enter.

feature wontfix

Most helpful comment

I'm using ChipInput with material-table, so to prevent enter from saving row, I set a key handler:

const handleKey = (e: React.KeyboardEvent<HTMLDivElement>) => {
  if (e.key === 'Enter') {
    e.stopPropagation()
  }
}

return (
  <ChipInput
    value={props.value}
    onAdd={add}
    onDelete={remove}
    newChipKeys={keys}
    onKeyDown={e => handleKey(e)}
  />
)

All 3 comments

Hi,

I have same problem, added multi-line rich text editor and cannot add new lines with enter press, because it saves record.
Add way to disable it or override the way it works would be great !

PS. material-table is great

I'm using ChipInput with material-table, so to prevent enter from saving row, I set a key handler:

const handleKey = (e: React.KeyboardEvent<HTMLDivElement>) => {
  if (e.key === 'Enter') {
    e.stopPropagation()
  }
}

return (
  <ChipInput
    value={props.value}
    onAdd={add}
    onDelete={remove}
    newChipKeys={keys}
    onKeyDown={e => handleKey(e)}
  />
)

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You can reopen it if it required.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

VipinJoshi picture VipinJoshi  路  3Comments

roseak picture roseak  路  3Comments

ps1011 picture ps1011  路  3Comments

Likurg2010 picture Likurg2010  路  3Comments

ModPhoenix picture ModPhoenix  路  3Comments