Moved to useBlur helper

This commit is contained in:
Mitchell McCaffrey
2021-03-19 13:29:07 +11:00
parent 0bc572cec2
commit cfdff1e549
3 changed files with 31 additions and 24 deletions

View File

@@ -1,4 +1,4 @@
import React, { useRef, useState, useEffect } from "react";
import React, { useRef, useState } from "react";
import { Button, Flex, Label } from "theme-ui";
import shortid from "shortid";
import Case from "case";
@@ -26,7 +26,7 @@ import useResponsiveLayout from "../hooks/useResponsiveLayout";
import { useMapData } from "../contexts/MapDataContext";
import { useAuth } from "../contexts/AuthContext";
import { useKeyboard } from "../contexts/KeyboardContext";
import { useKeyboard, useBlur } from "../contexts/KeyboardContext";
const defaultMapProps = {
showGrid: false,
@@ -382,17 +382,12 @@ function SelectMapModal({
useKeyboard(handleKeyDown, handleKeyUp);
// Set select mode to single when alt+tabing
useEffect(() => {
function handleBlur() {
setSelectMode("single");
}
// Set select mode to single when cmd+tabing
function handleBlur() {
setSelectMode("single");
}
window.addEventListener("blur", handleBlur);
return () => {
window.removeEventListener("blur", handleBlur);
};
}, []);
useBlur(handleBlur);
const layout = useResponsiveLayout();