workflow-kotlin icon indicating copy to clipboard operation
workflow-kotlin copied to clipboard

[kotlin] WorkflowViewStub breaks view back handling

Open zach-klippenstein opened this issue 5 years ago • 7 comments
trafficstars

If a LayoutRunner that is being used to render a view inside a WorkflowViewStub calls backPressedHandler = on the root view (the view passed to the LayoutRunner's constructor), that view is actually the parent view of the stub, so the back handler will be set on the stub's container. If another view doesn't replace the back handler in the stub's container, that handler will live beyond the lifetime of that screen.

To repro, see square/workflow#873.

zach-klippenstein avatar Jan 14 '20 19:01 zach-klippenstein

I wonder if we should scrap backPressedHandler and instead provide the OnBackPressedDispatcher in ContainerHints. Be a lot less magical.

rjrjr avatar Jan 14 '20 23:01 rjrjr

ModalViewContainer could just provide its own, a lot less crafty than what it's doing now.

rjrjr avatar Jan 14 '20 23:01 rjrjr

Downside is we lose the nice property of tearing things down when the view is detached. If we go this route, should still provide some help for that.

rjrjr avatar Jan 15 '20 00:01 rjrjr

the nice property of tearing things down when the view is detached

Seems like we don't always get this property anyway.

zach-klippenstein avatar Jan 15 '20 17:01 zach-klippenstein

How do you figure?

rjrjr avatar Jan 15 '20 17:01 rjrjr

Because that's what this issue is – the back handler isn't being torn down even after the "view" goes away.

zach-klippenstein avatar Jan 15 '20 17:01 zach-klippenstein

Not API change, not 1.0 blocker. Might also make most UI stuff ExperimentalWorkflowApi.

zach-klippenstein avatar Jun 27 '20 00:06 zach-klippenstein