Skip to content
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

[Bug]: Impossible to display a modal. #24189

Open
LamsaLL opened this issue Sep 15, 2023 · 8 comments
Open

[Bug]: Impossible to display a modal. #24189

LamsaLL opened this issue Sep 15, 2023 · 8 comments

Comments

@LamsaLL
Copy link

LamsaLL commented Sep 15, 2023

Describe the bug

I have a ModalButton component (in React). My component work well on my app but in my story, when i click on the button it does not display the modal.

To Reproduce

Here the code of my component :

"use client";

import React, {
  cloneElement,
  ComponentProps,
  FunctionComponent,
  ReactElement,
  ReactNode,
} from "react";
import useModal from "../../../hooks/useModal";
import Modal from "../Modal/Modal";

type ModalButtonProps = {
  trigger: ReactElement;
  modalProps?: Pick<
    ComponentProps<typeof Modal>,
    "className" | "header" | "leading" | "size" | "trailing" | "title"
  >;
  modalContent: ReactNode;
};

const ModalButton: FunctionComponent<ModalButtonProps> = ({
  trigger,
  modalProps,
  modalContent,
}) => {
  const modalState = useModal();

  return (
    <>
      {cloneElement(trigger, {
        onClick: (event: any) => {
          event?.preventDefault();
          modalState.open();
        },
      })}
      <Modal
        open={modalState.isOpen}
        onClose={modalState.close}
        {...modalProps}
      >
        {modalContent}
      </Modal>
    </>
  );
};

export default ModalButton;

The code of the story :

import { Meta, StoryObj } from "@storybook/react";
import Button from "../../components/elements/Button";
import ModalButton from "../../components/modules/ModalButton";

export default {
  title: "modules/ModalButton",
  component: ModalButton,
  args: {
    modalContent: <p>Modal content</p>,
  },
  argTypes: {
    trigger: { table: { disable: true } },
    modalContent: { table: { disable: true } },
    modalProps: { table: { disable: true } },
  },
} as Meta<typeof ModalButton>;

type Story = StoryObj<typeof ModalButton>;

export const ButtonTrigger: Story = {
  args: {
    trigger: <Button>Lorem ipsum</Button>,
  },
};
export const AnchorTrigger: Story = {
  args: {
    trigger: <Button as="a">Lorem ipsum</Button>,
  },
};

System

Environment Info:

  System:
    OS: Linux 5.4 Ubuntu 20.04.6 LTS (Focal Fossa)
    CPU: (16) x64 AMD Ryzen 7 2700 Eight-Core Processor
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.5.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 116.0.5845.187
  npmPackages:
    @storybook/addon-actions: ^7.3.1 => 7.3.2 
    @storybook/addon-essentials: ^7.3.1 => 7.3.2 
    @storybook/addon-interactions: ^7.3.1 => 7.3.2 
    @storybook/addon-links: ^7.3.1 => 7.3.2 
    @storybook/addon-mdx-gfm: ^7.3.1 => 7.3.2 
    @storybook/nextjs: ^7.3.1 => 7.3.2 
    @storybook/react: ^7.3.1 => 7.3.2 
    @storybook/testing-library: 0.2.0 => 0.2.0

Additional context

No response

@kmalap05
Copy link

kmalap05 commented Oct 2, 2023

I can help to solve this issue. Since, I am very much familiar with this issue.
Assign it to me with Hacktoberfest 2023.

@Rainnut
Copy link

Rainnut commented Dec 14, 2023

i have this problem too,when fix it ?

@valentinpalkovic
Copy link
Contributor

Hi @LamsaLL

My guess is that the Modal is displayed, but since Story iframes don't leak any content, you have to increase the visibility area to display it. I think this issue is connected to the following discussions and issues.

A feature request exists to implement a granular control of the zoom feature:

Please take a look at the DOM, whether the modal actually is displayed or not.

@Azgharpasha
Copy link

@LamsaLL I would like to contribute. But the above bug its difficult to trace . can some more specify exactly the bug and show the code in the storybook , where;s its actual rendering .

@harsh1898
Copy link

harsh1898 commented Jan 25, 2024

Hi @LamsaLL @Rainnut
Please provide some more brainstorming or your bug affected code repo about this issue. As per above thread comments, information is not sufficient to get into.

@shilman , Please confirm , is it really a bug that is coming from storybook code configuration. As, I suppose, this is not a typical bug as some configuration of storybook that I have initiated in my react code , is working fine

@harsh1898
Copy link

Hi @LamsaLL

My guess is that the Modal is displayed, but since Story iframes don't leak any content, you have to increase the visibility area to display it. I think this issue is connected to the following discussions and issues.

A feature request exists to implement a granular control of the zoom feature:

Please take a look at the DOM, whether the modal actually is displayed or not.

@valentinpalkovic , can you little elaborate, how these other issues are connected to this modal issue.

@harsh1898
Copy link

harsh1898 commented Jan 29, 2024

Hi @LamsaLL

With your provided code, I have tried to reproduce and fix the issue.
https://github.com/harsh1898/Modal_Story , this is my code repository. You can check it and gain some idea.

@Azgharpasha
Copy link

@LamsaLL
the solution provided by @harsh1898 its working fine for me and . once check the code in repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants