feat: make CreatePlaylistModal handle Enter key

This commit is contained in:
Andy Russo 2024-03-16 20:48:24 +05:00 committed by Bnyro
parent de0b0d1e5a
commit 34f52c953e
2 changed files with 13 additions and 1 deletions

View File

@ -24,7 +24,19 @@ export default {
playlistName: "",
};
},
mounted() {
window.addEventListener("keydown", this.handleKeyDown);
},
unmounted() {
window.removeEventListener("keydown", this.handleKeyDown);
},
methods: {
handleKeyDown(event) {
if (event.code === "Enter") {
this.onCreatePlaylist();
event.preventDefault();
}
},
onCreatePlaylist() {
if (!this.playlistName) return;

View File

@ -65,7 +65,7 @@ export default {
},
methods: {
handleKeyDown(event) {
if (event.code === "Enter") {
if (event.code === "Enter" && !this.showCreatePlaylistModal) {
this.handleClick(this.selectedPlaylist);
event.preventDefault();
}