From 0139b666d4a76144f5e9eed7673ec3c00e058242 Mon Sep 17 00:00:00 2001 From: Marks Polakovs Date: Thu, 18 Mar 2021 09:56:18 +0000 Subject: [PATCH] Defocus library dropdown when adding item In #163 we defocus the search box when we drag in an item. However, you can still select a non-music library, drag things in, have the dropdown stay focused, and thus eat hotkeys. This defocuses it as well. --- src/showplanner/index.tsx | 9 +++++++-- src/showplanner/libraries.tsx | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/showplanner/index.tsx b/src/showplanner/index.tsx index c15522e..b52627f 100644 --- a/src/showplanner/index.tsx +++ b/src/showplanner/index.tsx @@ -170,10 +170,15 @@ const Showplanner: React.FC<{ timeslotId: number }> = function({ timeslotId }) { ]) ); } - // If we're dragging from a pseudo-column, and a search field is focused, defocus it. + // If we're dragging from a pseudo-column, + // and a search field or library dropdown is focused, defocus it. if (result.source.droppableId[0] === "$") { const focus = document.activeElement; - if (focus && focus instanceof HTMLInputElement && focus.type === "text") { + if ( + (focus && focus instanceof HTMLInputElement && focus.type === "text") || + (focus instanceof HTMLSelectElement && + focus.id === "sidebarLibrarySelect") + ) { focus.blur(); } } diff --git a/src/showplanner/libraries.tsx b/src/showplanner/libraries.tsx index 82938db..da23c0c 100644 --- a/src/showplanner/libraries.tsx +++ b/src/showplanner/libraries.tsx @@ -115,6 +115,7 @@ export function LibraryColumn() {