deck icon indicating copy to clipboard operation
deck copied to clipboard

feat(core): added useShowModal that passes the application to the context in showModal

Open ranihorev opened this issue 4 years ago • 5 comments

Problem

Some components use the ApplicationContext inside of a modal, however, it's not part of the react tree and therefore can't use the context.

Solution

Added a new parameter - application - to showModal and created a new hook that passes the application from the context to showModal

ranihorev avatar Jun 20 '21 17:06 ranihorev

I think this problem would be better solved using react portals in showModal

christopherthielen avatar Jun 22 '21 03:06 christopherthielen

I agree, I was a bit surprised that we weren't using it but didn't want to update the current implementation, because it might break some of the existing usage unintentionally. Maybe I should introduce a new hook. What do you think?

On Tue, Jun 22, 2021 at 06:07 Chris Thielen @.***> wrote:

I think this problem would be better solved using react portals in showModal

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/spinnaker/deck/pull/9363#issuecomment-865492518, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEC2OROQD5AR27QWDCV27JTTT746FANCNFSM47AI5WYA .

ranihorev avatar Jun 22 '21 03:06 ranihorev

can you explain why adding a portal might break current uses? TBH I'm a bit surprised we arent already doing this in showModal too.

christopherthielen avatar Jun 22 '21 19:06 christopherthielen

When using portal event bubbling and contexts work differently (they work 🙃). While it probably won't affect the existing modal, I can't say that for sure.

On Tue, Jun 22, 2021 at 22:51 Chris Thielen @.***> wrote:

can you explain why adding a portal might break current uses? TBH I'm a bit surprised we arent already doing this in showModal.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/spinnaker/deck/pull/9363#issuecomment-866285929, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEC2ORJVG4HL6ZBZWHGQAUTTUDST3ANCNFSM47AI5WYA .

ranihorev avatar Jun 22 '21 20:06 ranihorev

When using portal event bubbling and contexts work differently (they work 🙃). While it probably won't affect the existing modal, I can't say that for sure.

The current workflow won't fit portal afaik. It has to be rendered as a react component and not via a function call (i.e. showModal). We might be able to add a separate workflow for that

ranihorev avatar Jun 24 '21 11:06 ranihorev