Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

fix(Dropdown): Remove timeouts, Fix ref bug #42

Merged
merged 20 commits into from
May 15, 2019
9 changes: 7 additions & 2 deletions src/Dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ const Trigger = createComponent({
`,
});

let isBlurable = false;

const setBlurable = value => {
isBlurable = value;
}
kylealwyn marked this conversation as resolved.
Show resolved Hide resolved

export default function Dropdown({
autoclose,
placement,
Expand All @@ -54,7 +60,6 @@ export default function Dropdown({
const menuRef = useRef();

const [isOpen, setOpen] = useState(false);
const [isBlurable, setBlurable] = useState(false);

const open = () => {
setBlurable(true);
Expand All @@ -70,8 +75,8 @@ export default function Dropdown({
// Allow all clicks and, for non-button elements, Enter and Space to toggle Dropdown
// https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/button_role#Required_JavaScript_Features
if (e.type === 'click' || (e.type === 'keypress' && (e.which === 13 || e.which === 32))) {
e.stopPropagation();
e.preventDefault();
cehsu marked this conversation as resolved.
Show resolved Hide resolved
e.stopPropagation();
toggle();
}
};
Expand Down
2 changes: 2 additions & 0 deletions src/Dropdown/Dropdown.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Icon from '../Icon';
import Flex from '../Flex';
import RadioGroup from '../Form/RadioGroup';
import Button from '../Button';
import Input from '../Form/Input';

# Dropdown

Expand Down Expand Up @@ -114,6 +115,7 @@ Easily display contextual overlays using custom trigger elements. Dropdown's pos
</Dropdown>
</Flex>
</Button.Group>
<Input name="password" label="Password" />
kylealwyn marked this conversation as resolved.
Show resolved Hide resolved
kylealwyn marked this conversation as resolved.
Show resolved Hide resolved
cehsu marked this conversation as resolved.
Show resolved Hide resolved
</>
);
}
Expand Down