Skip to content

Commit

Permalink
fix: Sorting elements use updated focus handlers to not drag inputs. (#…
Browse files Browse the repository at this point in the history
…226)

Uses upstream fix for sortable to not allow dragging when there is a form input in focus.
  • Loading branch information
Zoramite committed Aug 12, 2021
1 parent 4c8c210 commit 4a5e008
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"webpack-merge": "^5.8.0"
},
"dependencies": {
"@blinkk/selective-edit": "^3.1.0",
"@blinkk/selective-edit": "^3.2.0",
"@toast-ui/editor": "^3.0.2",
"bent": "^7.3.12",
"codemirror": "^5.62.2",
Expand Down
21 changes: 20 additions & 1 deletion src/ts/editor/field/mediaList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ class MediaListFieldItem
'selective__media_list__item--no-drag': this.listField.length <= 1,
selective__sortable: true,
})}
draggable=${canDrag ? 'true' : 'false'}
draggable=${canDrag && sortable.canDrag ? 'true' : 'false'}
data-index=${index}
@dragenter=${(evt: DragEvent) => {
sortable.handleDragEnter(evt);
Expand All @@ -551,6 +551,14 @@ class MediaListFieldItem
sortable.handleDrop(evt);
droppable.handleDrop(evt);
}}
@focusin=${(evt: FocusEvent) => {
sortable.handleFocusIn(evt);
this.listField.render();
}}
@focusout=${(evt: FocusEvent) => {
sortable.handleFocusOut(evt);
this.listField.render();
}}
>
<div
class="selective__media_list__item__preview"
Expand All @@ -570,14 +578,25 @@ class MediaListFieldItem
data: DeepObject,
index: number
): TemplateResult {
const canDrag = this.listField.length > 1;
const sortable = this.listField.sortableUi;
return html` <div
class="selective__media_list__item selective__media_list__item--expanded selective__sortable"
draggable=${canDrag && sortable.canDrag ? 'true' : 'false'}
data-index=${index}
@dragenter=${sortable.handleDragEnter.bind(sortable)}
@dragleave=${sortable.handleDragLeave.bind(sortable)}
@dragover=${sortable.handleDragOver.bind(sortable)}
@dragstart=${sortable.handleDragStart.bind(sortable)}
@drop=${sortable.handleDrop.bind(sortable)}
@focusin=${(evt: FocusEvent) => {
sortable.handleFocusIn(evt);
this.listField.render();
}}
@focusout=${(evt: FocusEvent) => {
sortable.handleFocusOut(evt);
this.listField.render();
}}
>
<div
class="selective__media_list__fields__header"
Expand Down
2 changes: 1 addition & 1 deletion src/ts/editor/ui/parts/menu/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
html,
} from '@blinkk/selective-edit';
import {DialogActionLevel, FormDialogModal} from '../../modal';
import {EVENT_FILE_LOAD, EVENT_RENDER_COMPLETE} from '../../../events';
import {
IncludeExcludeFilter,
IncludeExcludeFilterConfig,
Expand All @@ -18,7 +19,6 @@ import {
import {MenuSectionPart, MenuSectionPartConfig} from './index';

import {DataStorage} from '../../../../utility/dataStorage';
import {EVENT_FILE_LOAD, EVENT_RENDER_COMPLETE} from '../../../events';
import {RuleConfig} from '@blinkk/selective-edit/dist/selective/validationRules';
import {StatePromiseKeys} from '../../../state';
import {repeat} from '@blinkk/selective-edit';
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@
"@babel/helper-validator-identifier" "^7.14.9"
to-fast-properties "^2.0.0"

"@blinkk/selective-edit@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@blinkk/selective-edit/-/selective-edit-3.1.0.tgz#6c8e52347db8e0c17d7fcc25c364cd34175a92b7"
integrity sha512-btUdFpjio592QsUYpBCPfwY+yy+7ASuTSVDNkekkFCa9EfoqCYlutBGknqsabWnJvTCRaemU1NuDhmYTGftiLQ==
"@blinkk/selective-edit@^3.2.0":
version "3.2.0"
resolved "https://registry.yarnpkg.com/@blinkk/selective-edit/-/selective-edit-3.2.0.tgz#5f4c89053d4ba8aeabca924455c0bc44dd7a244b"
integrity sha512-xhljgOCSriIQSqBhzmM+MDYnG4JMiWWL/ztkFt7Zjx+WHnmXNniig3fiY534Kun30z12VaiReBiJqtKQaAu1Kw==
dependencies:
json-stable-stringify "^1.0.1"
lit-html "^1.4.1"
Expand Down

0 comments on commit 4a5e008

Please sign in to comment.