Skip to content
This repository was archived by the owner on Nov 9, 2024. It is now read-only.
This repository was archived by the owner on Nov 9, 2024. It is now read-only.

ESC key should hide tooltip for accessibility #386

@marchingband

Description

@marchingband

I achieved it like this, but it should be built in, it is an accessibility requirement.

  const [hide, setHide] = useState(false)
  const onKeyPress = useCallback(e=>{
    if(e.key == "Escape"){
      setHide(true)
    }
  }, [hide, setHide])
  const handleShow = useCallback(()=>{
    document.addEventListener("keydown", onKeyPress, true)
  }, [onKeyPress])
  const handleHide = useCallback(()=>{
    setHide(false)
    document.removeEventListener("keydown", onKeyPress, true)
  }, [onKeyPress, setHide])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions