File tree Expand file tree Collapse file tree
src/components/profile/edit Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3535 >
3636 </Tag >
3737 </div >
38+ <!-- add new tag when pressing either the enter or the comma key (keyCode: 188) -->
3839 <input
3940 v-if =" addingTag"
4041 type =" text"
4142 v-model =" newTag"
4243 ref =" inputTag"
4344 class =" add-tags__input"
4445 @keydown.enter =" handleAddTag"
46+ @keydown.188.prevent =" handleAddTag"
47+ @paste =" handlePaste"
4548 />
4649 <button
4750 type =" button"
@@ -95,7 +98,6 @@ export default {
9598 }
9699 if (this .newTag .length > 0 ) {
97100 this .addTag (this .newTag );
98- this .addingTag = false ;
99101 } else {
100102 this .$refs .inputTag .focus ();
101103 }
@@ -118,6 +120,19 @@ export default {
118120 this .tags .values .splice (index, 1 );
119121 }
120122 },
123+ handlePaste () {
124+ this .$nextTick (() => {
125+ let text = this .$refs .inputTag .value ;
126+
127+ if (text === ' ' || ! text .includes (' ,' )) {
128+ return ;
129+ }
130+
131+ for (let tag of text .split (' ,' )) {
132+ this .addTag (tag .trim ());
133+ }
134+ });
135+ },
121136 },
122137 mounted () {
123138 this .$refs .header .focus ();
You can’t perform that action at this time.
0 commit comments