Skip to content

Commit

Permalink
fix(EditableCell): Prevent save when not edited
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianaCeric committed Oct 26, 2023
1 parent 8b1093d commit f70c6f3
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/editor/components/timetable/EditableCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ function EditableCell (props: Props) {
offsetScrollCol,
offsetScrollRow
} = props
const {isEditing} = state
const {isEditing, data, originalData} = state
switch (evt.keyCode) {
case 13: // Enter
evt.preventDefault()
if (isFocused) {
if (isFocused && isEditing && data !== originalData) {
beginEditing()
save()
// handle shift
Expand All @@ -135,7 +135,9 @@ function EditableCell (props: Props) {
// save and advance to next cell if editing
evt.preventDefault()
evt.stopPropagation()
save()
if (isEditing && data !== originalData) {
save()
}
offsetScrollCol(evt.shiftKey ? -1 : 1)
break

Expand Down Expand Up @@ -232,7 +234,10 @@ function EditableCell (props: Props) {
}

const handleBlur = () => {
save()
const {isEditing, data, originalData} = state
if (isEditing && data !== originalData) {
save()
}
}

const handleChange = (evt) => {
Expand Down Expand Up @@ -302,7 +307,7 @@ function EditableCell (props: Props) {
}
const cellHtml = isEditing
? <input
/* enable autofocus against jsx-a11y`s best judget so the inputs behave
/* enable autofocus against jsx-a11y`s best judgement so the inputs behave
like a spreadsheet where cells are automatically in edit mode when
selected */
/* eslint-disable-next-line jsx-a11y/no-autofocus */
Expand Down

0 comments on commit f70c6f3

Please sign in to comment.