Fix bug with multi select and alt+tab

This commit is contained in:
Mitchell McCaffrey
2020-10-10 11:29:42 +11:00
parent 21bed5b710
commit fb6e7e036b
2 changed files with 26 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
import React, { useRef, useContext, useState } from "react";
import React, { useRef, useContext, useState, useEffect } from "react";
import { Flex, Label, Button } from "theme-ui";
import shortid from "shortid";
import Case from "case";
@@ -183,6 +183,18 @@ function SelectTokensModal({ isOpen, onRequestClose }) {
useKeyboard(handleKeyDown, handleKeyUp);
// Set select mode to single when alt+tabing
useEffect(() => {
function handleBlur() {
setSelectMode("single");
}
window.addEventListener("blur", handleBlur);
return () => {
window.removeEventListener("blur", handleBlur);
};
}, []);
return (
<Modal
isOpen={isOpen}