Code Monkey home page Code Monkey logo

Comments (5)

yihuiliao avatar yihuiliao commented on May 25, 2024 2

Thanks for the feedback! We do briefly mention here that "by default, Modal includes a builtin ModalOverlay, which renders a backdrop over the page when a modal is open". Though you do have to scroll pretty far down to read it and it still might not be super obvious. I think we could probably add more to the custom overlay section so that it's less confusing.

from react-spectrum.

psirenny avatar psirenny commented on May 25, 2024

@syedtaqi95 were you able to get isDismissable to work when set on the ModalOverlay component? I've found that custom overlays don't receive click/press events.

from react-spectrum.

syedtaqi95 avatar syedtaqi95 commented on May 25, 2024

@psirenny yes, isDismissable works fine for me when I set it directly on the ModalOverlay.

Are you using a controlled Modal, i.e. passing isOpen to the ModalOverlay? If so, you need to make sure that isOpen is set to False when the onOpenChange event fires (as per the example in the docs here).

from react-spectrum.

psirenny avatar psirenny commented on May 25, 2024

It's just an ordinary uncontrolled Modal. Essentially this:

<DialogTrigger>
  <Button>Trigger</Button>
  <ModalOverlay isDismissable>
    <Modal>
      <Dialog>
        {/* … */}
      </Dialog>
    </Modal>
  </ModalOverlay>
</DialogTrigger>

Adapted from the Destructive Alert Dialog example. I noticed that the Modal component is also creating its own internal overlay (not the one specified), but it's screen hidden.

Edit: I've tried setting isDismissable on the other components as well 😛.

from react-spectrum.

syedtaqi95 avatar syedtaqi95 commented on May 25, 2024

@psirenny I'm not sure why it's not working for you, sorry.

FYI, I am developing my Modal in Storybook, so the component runs in an isolated iframe. This is what I am rendering in the iframe:

<div className="mx-4 flex max-w-4xl flex-col items-center gap-8">
  <DialogTrigger>
    <Button>Sign up...</Button>
    <ModalOverlay  {...props}>
      <Modal>

        <Dialog>
          {({ close }) => (
            <>
              <DialogHeading>Dialog with Button Group</DialogHeading>
              <div>
                Lorem ipsum dolor sit amet, qui minim labore adipisicing minim
                sint cillum sint consectetur cupidatat.
              </div>
              <ButtonGroup align="end" className="w-full">
                <Button variant="quiet" onPress={close}>
                  Cancel
                </Button>
                <Button colour="secondary" onPress={close} autoFocus>
                  Confirm
                </Button>
              </ButtonGroup>
            </>
          )}
        </Dialog>

      </Modal>
    </ModalOverlay>
  </DialogTrigger>

  <p className="text-justify">
    Lorem ipsum dolor sit amet, officia excepteur ex fugiat reprehenderit
    enim labore culpa sint ad nisi Lorem pariatur mollit ex esse
    exercitation amet. Nisi anim cupidatat excepteur officia.
    Reprehenderit nostrud nostrud ipsum Lorem est aliquip amet voluptate
    voluptate dolor minim nulla est proident. Nostrud officia pariatur ut
    officia. Sit irure elit esse ea nulla sunt ex occaecat reprehenderit
    commodo officia dolor Lorem duis laboris cupidatat officia voluptate.
    Culpa proident adipisicing id nulla nisi laboris ex in Lorem sunt duis
    officia eiusmod. Aliqua reprehenderit commodo ex non excepteur duis
    sunt velit enim. Voluptate laboris sint cupidatat ullamco ut ea
    consectetur et est culpa et culpa duis.
  </p>
</div>

So I am simply setting the props on the ModalOverlay which works ok for me.

from react-spectrum.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.