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

Support creating a new node and editing node with languages that requires an IME #1638

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
prevented to submit when typing enter with an IME
  • Loading branch information
mYanagimura committed May 9, 2020
commit fb3c3a5c2a9d8a11dfd88448d021057bbda80664
16 changes: 12 additions & 4 deletions src/components/ExplorerNode.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="explorer-node" :class="{'explorer-node--selected': isSelected, 'explorer-node--folder': node.isFolder, 'explorer-node--open': isOpen, 'explorer-node--trash': node.isTrash, 'explorer-node--temp': node.isTemp, 'explorer-node--drag-target': isDragTargetFolder}" @dragover.prevent @dragenter.stop="node.noDrop || setDragTarget(node)" @dragleave.stop="isDragTarget && setDragTarget()" @drop.prevent.stop="onDrop" @contextmenu="onContextMenu">
<div class="explorer-node__item-editor" v-if="isEditing" :style="{paddingLeft: leftPadding}" draggable="true" @dragstart.stop.prevent>
<input type="text" class="text-input" v-focus @blur="submitEdit()" @keydown.stop @keydown.enter="submitEdit()" @keydown.esc.stop="submitEdit(true)" v-model="editingNodeName">
<input type="text" class="text-input" v-focus @blur="submitEdit(false, $event)" @keydown.stop @keydown.enter="submitEdit(false, $event)" @keydown.esc.stop="submitEdit(true, $event)" v-model="editingNodeName">
</div>
<div class="explorer-node__item" v-else :style="{paddingLeft: leftPadding}" @click="select()" draggable="true" @dragstart.stop="setDragSourceId" @dragend.stop="setDragTarget()">
{{node.item.name}}
Expand All @@ -10,7 +10,7 @@
<div class="explorer-node__children" v-if="node.isFolder && isOpen">
<explorer-node v-for="node in node.folders" :key="node.item.id" :node="node" :depth="depth + 1"></explorer-node>
<div v-if="newChild" class="explorer-node__new-child" :class="{'explorer-node__new-child--folder': newChild.isFolder}" :style="{paddingLeft: childLeftPadding}">
<input type="text" class="text-input" v-focus @blur="submitNewChild()" @keydown.stop @keydown.enter="submitNewChild()" @keydown.esc.stop="submitNewChild(true)" v-model.trim="newChildName">
<input type="text" class="text-input" v-focus @blur="submitNewChild(false, $event)" @keydown.stop @keydown.enter="submitNewChild(false, $event)" @keydown.esc.stop="submitNewChild(true, $event)" v-model.trim="newChildName">
</div>
<explorer-node v-for="node in node.files" :key="node.item.id" :node="node" :depth="depth + 1"></explorer-node>
</div>
Expand Down Expand Up @@ -99,7 +99,11 @@ export default {
}
return true;
},
async submitNewChild(cancel) {
async submitNewChild(cancel, evt) {
if (evt.keyCode === 229) {
evt.target.focus();
return;
}
const { newChildNode } = store.state.explorer;
if (!cancel && !newChildNode.isNil && newChildNode.item.name) {
try {
Expand All @@ -118,7 +122,11 @@ export default {
}
store.commit('explorer/setNewItem', null);
},
async submitEdit(cancel) {
async submitEdit(cancel, evt) {
if (evt.keyCode === 229) {
evt.target.focus();
return;
}
const { item, isFolder } = store.getters['explorer/editingNode'];
const value = this.editingValue;
this.setEditingId(null);
Expand Down