Skip to content

Commit

Permalink
feat: prevent sort start on contentEditable target
Browse files Browse the repository at this point in the history
  • Loading branch information
Clauderic Demers committed Mar 20, 2019
1 parent 5337c97 commit d64c8cf
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/SortableContainer/defaultShouldCancelStart.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import {NodeType} from '../utils';
import {NodeType, closest} from '../utils';

export default function defaultShouldCancelStart(event) {
// Cancel sorting if the event target is an `input`, `textarea`, `select` or `option`
const disabledElements = [
const interactiveElements = [
NodeType.Input,
NodeType.Textarea,
NodeType.Select,
NodeType.Option,
NodeType.Button,
];

if (disabledElements.indexOf(event.target.tagName) !== -1) {
if (interactiveElements.indexOf(event.target.tagName) !== -1) {
// Return true to cancel sorting
return true;
}

if (closest(event.target, (el) => el.contentEditable === 'true')) {
return true;
}

return false;
}

0 comments on commit d64c8cf

Please sign in to comment.