Skip to content

Commit

Permalink
feat(Modal): change context value of contentScrolled to isContentScro…
Browse files Browse the repository at this point in the history
…lled

per to CR request
  • Loading branch information
YossiSaadi committed Oct 20, 2024
1 parent 5819126 commit ebcf078
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe("ModalContent", () => {
modalId: "modal-id",
setTitleId: jest.fn(),
setDescriptionId: jest.fn(),
contentScrolled: false,
isContentScrolled: false,
setContentScrolled: jest.fn()
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe("ModalHeader", () => {
modalId: "modal-id",
setTitleId: jest.fn(),
setDescriptionId: jest.fn(),
contentScrolled: false,
isContentScrolled: false,
setContentScrolled: jest.fn()
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { ModalContextProps, ModalProviderProps } from "./ModalContext.types";
const ModalContext = createContext<ModalContextProps | undefined>(undefined);

export const ModalProvider = ({ value, children }: ModalProviderProps) => {
const [contentScrolled, setContentScrolled] = useState<boolean>(false);
const [isContentScrolled, setContentScrolled] = useState<boolean>(false);

const contextValue = useMemo<ModalContextProps>(
() => ({
...value,
contentScrolled,
isContentScrolled,
setContentScrolled: (newContentScrolled: boolean) => setContentScrolled(newContentScrolled)
}),
[contentScrolled, value]
[isContentScrolled, value]
);

return <ModalContext.Provider value={contextValue}>{children}</ModalContext.Provider>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";

export interface ModalContextProps extends ModalProviderValue {
contentScrolled: boolean;
isContentScrolled: boolean;
setContentScrolled: (scrolled: boolean) => void;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const ModalBasicLayout = forwardRef(
ref: React.ForwardedRef<HTMLDivElement>
) => {
const [header, content] = React.Children.toArray(children);
const { contentScrolled } = useModal();
const { isContentScrolled } = useModal();

return (
<Flex
Expand All @@ -26,7 +26,7 @@ const ModalBasicLayout = forwardRef(
data-testid={dataTestId || getTestId(ComponentDefaultTestId.MODAL_NEXT_BASIC_LAYOUT, id)}
>
<div className={styles.header}>{header}</div>
{contentScrolled && <Divider className={styles.divider} withoutMargin />}
{isContentScrolled && <Divider className={styles.divider} withoutMargin />}
<div className={styles.content}>{content}</div>
</Flex>
);
Expand Down

0 comments on commit ebcf078

Please sign in to comment.