Defocus library dropdown when adding item

This commit is contained in:
Marks Polakovs 2021-03-18 09:56:18 +00:00 committed by Matthew Stratford
parent f123249331
commit 0d324ed379

View file

@ -86,6 +86,7 @@ function LibraryColumn() {
</div>
<div className="px-2">
<select
id="sidebarLibrarySelect"
className="form-control form-control-sm"
style={{ flex: "none" }}
value={sauce}
@ -218,10 +219,15 @@ const Showplanner: React.FC = function() {
])
);
}
// 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();
}
}