Skip to content

Commit

Permalink
feat(group title): adds additional mouse listener, focus and selection (
Browse files Browse the repository at this point in the history
  • Loading branch information
2xAA authored Apr 8, 2023
1 parent 888ed83 commit 4b54059
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/components/Group.vue
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
}}</span>
<TextInput
v-model="localName"
ref="titleInput"
v-else
@keypress.enter="endTitleEditable"
/>
Expand Down Expand Up @@ -285,6 +286,10 @@ export default {
}
},
beforeDestroy() {
window.removeEventListener("mousedown", this.endTitleEditable);
},
computed: {
groups() {
return this.$modV.store.state.groups.groups.filter(
Expand Down Expand Up @@ -482,9 +487,23 @@ export default {
toggleTitleEditable() {
this.titleEditable = !this.titleEditable;
if (this.titleEditable) {
window.addEventListener("mousedown", this.endTitleEditable);
this.$nextTick(() => {
this.$refs.titleInput.$el.focus();
this.$refs.titleInput.$el.select();
});
}
},
endTitleEditable() {
endTitleEditable(e) {
if (e.target === this.$refs.titleInput.$el) {
return;
}
window.removeEventListener("mousedown", this.endTitleEditable);
const { localName } = this;
const trimmedName = localName.trim();
Expand Down

0 comments on commit 4b54059

Please sign in to comment.