Skip to content

Commit

Permalink
Merge pull request #7 from navedqb/fix--speed-dial-menu-not-closing-o…
Browse files Browse the repository at this point in the history
…n-escape

fix: fix speed dial menu not closing on escape key press
  • Loading branch information
navedqb authored Nov 22, 2023
2 parents ea8470b + fb3e388 commit 1599ff2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion components/lib/speeddial/SpeedDial.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { PrimeReactContext } from '../api/Api';
import { Button } from '../button/Button';
import { useHandleStyle } from '../componentbase/ComponentBase';
import { useEventListener, useMountEffect, useUpdateEffect } from '../hooks/Hooks';
import { useEventListener, useMountEffect, useUpdateEffect, useOnEscapeKey } from '../hooks/Hooks';
import { MinusIcon } from '../icons/minus';
import { PlusIcon } from '../icons/plus';
import { Ripple } from '../ripple/Ripple';
Expand Down Expand Up @@ -40,6 +40,8 @@ export const SpeedDial = React.memo(
when: visibleState
});

useOnEscapeKey(elementRef, visible, () => hide());

const show = () => {
props.onVisibleChange ? props.onVisibleChange(true) : setVisibleState(true);
props.onShow && props.onShow();
Expand Down

0 comments on commit 1599ff2

Please sign in to comment.