fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

Request: specifying a “modal host” when rendering a modal

Open gscottolson opened this issue 8 years ago • 4 comments

Is it possible to mount a modal at a predetermined location in the React component tree? I don’t think it can happen with the current implementation, but would you be open to accepting a PR for this?

Testing my styled modal becomes difficult when Fabric decides to mount the modal outside the rendered component. I am currently using Jest (and styled-components). A snapshot for a modal is something similar to <span class="ms-Layer" />. I can scour the DOM for the element with a ms-Layer--fixed class, but the found node doesn’t contain the serializable styled-component styles that are available with other styled Fabric components.

Another avenue would be to create my own modal using a layer and a layer host, but I wanted to make sure I wasn’t missing something obvious.

gscottolson avatar Dec 19 '17 22:12 gscottolson

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions to Fabric React!

stale[bot] avatar Apr 11 '18 06:04 stale[bot]

@gscottolson I am not sure I follow completely but, if you want a modalHost that functions like LayerHost, then use layer. Modal is a component designed to be fixed in the view, not to a component. Layer is the component you want to use.

oengusmacinog-zz avatar Apr 19 '18 22:04 oengusmacinog-zz

Closing this for now. If you are still having an issue, please feel free to reopen this issue or open a new one.

oengusmacinog-zz avatar Apr 24 '18 19:04 oengusmacinog-zz

I also encounter problem similar to this! I have created a component base on Fabric Dialog component, but when I test it using Jest, the snapshot is also <span class="ms-Layer" />, in addition, I couldn't use enzyme to find the expected element and simulate an event against it. Is there some helpful advice?

levid-gc avatar Jun 21 '18 14:06 levid-gc