From 34f52c953e54fc99985a63396d64caf73e5d2428 Mon Sep 17 00:00:00 2001 From: Andy Russo <88431411+AndyRusso@users.noreply.github.com> Date: Sat, 16 Mar 2024 20:48:24 +0500 Subject: [PATCH] feat: make CreatePlaylistModal handle Enter key --- src/components/CreatePlaylistModal.vue | 12 ++++++++++++ src/components/PlaylistAddModal.vue | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/CreatePlaylistModal.vue b/src/components/CreatePlaylistModal.vue index 180f162a..43f026f1 100644 --- a/src/components/CreatePlaylistModal.vue +++ b/src/components/CreatePlaylistModal.vue @@ -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; diff --git a/src/components/PlaylistAddModal.vue b/src/components/PlaylistAddModal.vue index 79088bd5..10910b56 100644 --- a/src/components/PlaylistAddModal.vue +++ b/src/components/PlaylistAddModal.vue @@ -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(); }