Skip to content

Picker - ExpandableOverlay imperativeCloseExpandable #3536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion src/components/picker/__tests__/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('Picker', () => {
expect(driver.isOpen()).toBeTruthy();
driver.cancel();
expect(driver.isOpen()).toBeFalsy();
expect(onDismiss).toHaveBeenCalledTimes(2); // TODO: this should be 1
expect(onDismiss).toHaveBeenCalledTimes(1);
});

// TODO: this test is not passing yet
Expand Down
7 changes: 6 additions & 1 deletion src/incubator/expandableOverlay/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ const ExpandableOverlay = (props: ExpandableOverlayProps, ref: any) => {
useDialog ? dialogProps?.onDismiss?.() : modalProps?.onDismiss?.();
}, [useDialog, dialogProps?.onDismiss, modalProps?.onDismiss, focusAccessibility]);

const dismissModal = useCallback(() => {
setExpandableVisible(false);
focusAccessibility();
}, [focusAccessibility]);

const toggleExpandable = useCallback(() => (visible ? closeExpandable() : openExpandable()),
[visible, openExpandable, closeExpandable]);

Expand All @@ -104,7 +109,7 @@ const ExpandableOverlay = (props: ExpandableOverlayProps, ref: any) => {
overlayBackgroundColor={Colors.$backgroundDefault}
{...modalProps}
visible={visible}
onDismiss={closeExpandable}
onDismiss={dismissModal}
onRequestClose={closeExpandable}
onBackgroundPress={closeExpandable}
>
Expand Down