Skip to content

Commit

Permalink
chore: rollback pr3467
Browse files Browse the repository at this point in the history
  • Loading branch information
wingkwong committed Sep 15, 2024
1 parent 1afe5b1 commit 32dd4f5
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 35 deletions.
2 changes: 2 additions & 0 deletions .changeset/silly-rockets-fly.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
"@nextui-org/autocomplete": patch
"@nextui-org/date-picker": patch
"@nextui-org/dropdown": patch
"@nextui-org/modal": patch
"@nextui-org/popover": patch
Expand Down
1 change: 1 addition & 0 deletions packages/components/autocomplete/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"react-dom": ">=18"
},
"dependencies": {
"@nextui-org/aria-utils": "workspace:*",
"@nextui-org/button": "workspace:*",
"@nextui-org/input": "workspace:*",
"@nextui-org/listbox": "workspace:*",
Expand Down
4 changes: 4 additions & 0 deletions packages/components/autocomplete/src/use-autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {chain, mergeProps} from "@react-aria/utils";
import {ButtonProps} from "@nextui-org/button";
import {AsyncLoadable, PressEvent} from "@react-types/shared";
import {useComboBox} from "@react-aria/combobox";
import {ariaShouldCloseOnInteractOutside} from "@nextui-org/aria-utils";

interface Props<T> extends Omit<HTMLNextUIProps<"input">, keyof ComboBoxProps<T>> {
/**
Expand Down Expand Up @@ -443,6 +444,9 @@ export function useAutocomplete<T extends object>(originalProps: UseAutocomplete
),
}),
},
shouldCloseOnInteractOutside: popoverProps?.shouldCloseOnInteractOutside
? popoverProps.shouldCloseOnInteractOutside
: (element: Element) => ariaShouldCloseOnInteractOutside(element, inputWrapperRef, state),
// when the popover is open, the focus should be on input instead of dialog
// therefore, we skip dialog focus here
disableDialogFocus: true,
Expand Down
1 change: 1 addition & 0 deletions packages/components/date-picker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
},
"dependencies": {
"@internationalized/date": "^3.5.4",
"@nextui-org/aria-utils": "workspace:*",
"@nextui-org/button": "workspace:*",
"@nextui-org/calendar": "workspace:*",
"@nextui-org/date-input": "workspace:*",
Expand Down
4 changes: 4 additions & 0 deletions packages/components/date-picker/src/use-date-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {useDatePickerState} from "@react-stately/datepicker";
import {AriaDatePickerProps, useDatePicker as useAriaDatePicker} from "@react-aria/datepicker";
import {clsx, dataAttr, objectToDeps} from "@nextui-org/shared-utils";
import {mergeProps} from "@react-aria/utils";
import {ariaShouldCloseOnInteractOutside} from "@nextui-org/aria-utils";

import {useDatePickerBase} from "./use-date-picker-base";

Expand Down Expand Up @@ -192,6 +193,9 @@ export function useDatePicker<T extends DateValue>({
),
}),
},
shouldCloseOnInteractOutside: popoverProps?.shouldCloseOnInteractOutside
? popoverProps.shouldCloseOnInteractOutside
: (element: Element) => ariaShouldCloseOnInteractOutside(element, popoverTriggerRef, state),
};
};

Expand Down
5 changes: 5 additions & 0 deletions packages/components/date-picker/src/use-date-range-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {useDateRangePicker as useAriaDateRangePicker} from "@react-aria/datepick
import {clsx, dataAttr, objectToDeps} from "@nextui-org/shared-utils";
import {mergeProps} from "@react-aria/utils";
import {dateRangePicker, dateInput, cn} from "@nextui-org/theme";
import {ariaShouldCloseOnInteractOutside} from "@nextui-org/aria-utils";

import {useDatePickerBase} from "./use-date-picker-base";
interface Props<T extends DateValue>
Expand Down Expand Up @@ -214,6 +215,10 @@ export function useDateRangePicker<T extends DateValue>({
props.className,
),
}),
shouldCloseOnInteractOutside: popoverProps?.shouldCloseOnInteractOutside
? popoverProps.shouldCloseOnInteractOutside
: (element: Element) =>
ariaShouldCloseOnInteractOutside(element, popoverTriggerRef, state),
},
} as PopoverProps;
};
Expand Down
1 change: 1 addition & 0 deletions packages/components/dropdown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"react-dom": ">=18"
},
"dependencies": {
"@nextui-org/aria-utils": "workspace:*",
"@nextui-org/menu": "workspace:*",
"@nextui-org/popover": "workspace:*",
"@nextui-org/react-utils": "workspace:*",
Expand Down
35 changes: 0 additions & 35 deletions packages/components/modal/__tests__/modal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from "react";
import {act, render, fireEvent} from "@testing-library/react";
import userEvent from "@testing-library/user-event";

import {Modal, ModalContent, ModalBody, ModalHeader, ModalFooter} from "../src";

Expand Down Expand Up @@ -109,38 +108,4 @@ describe("Modal", () => {
fireEvent.keyDown(modal, {key: "Escape"});
expect(onClose).toHaveBeenCalledTimes(1);
});

it("should only hide the top-most modal", async () => {
const onClose1 = jest.fn();
const onClose2 = jest.fn();

render(
<Modal isOpen onClose={onClose1}>
<ModalContent>
<ModalHeader>Modal header</ModalHeader>
<ModalBody>Modal body</ModalBody>
<ModalFooter>Modal footer</ModalFooter>
</ModalContent>
</Modal>,
);

const wrapper2 = render(
<Modal isOpen onClose={onClose2}>
<ModalContent>
<ModalHeader>Modal header</ModalHeader>
<ModalBody>Modal body</ModalBody>
<ModalFooter>Modal footer</ModalFooter>
</ModalContent>
</Modal>,
);

await userEvent.click(document.body);
expect(onClose1).not.toHaveBeenCalled();
expect(onClose2).toHaveBeenCalledTimes(1);

wrapper2.unmount();

await userEvent.click(document.body);
expect(onClose1).toHaveBeenCalledTimes(1);
});
});
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 32dd4f5

Please sign in to comment.