I AM SORRY for not providing the complete, best approach right away.
In E151 we connected turbo frame modals
with the html dialog element.
However this approach was not optimal:
- We were needlessly adding a stimulus controller on the BODY html tag;
- dialog html was present in the layout file, even if we do not need it right now;
Let's clean up the mess and make our modals even better! β¨
Special thanks to @ledockol for pushing me on this one! πͺ
Episode source code: https://github.com/corsego/151-dialog-turbo-modals/commit/6f4869005c28aca372319cc4f0f9e7e1ddd8a0e1
Based on this blogpost: https://blog.corsego.com/turbo-modal-dialog#refactoring
0:00 old implementation
0:38 I AM SORRY
1:12 move modal dialog from body to new.html.erb
5:40 reusable dialog wrapper
7:59 restrict opening modals in new tabs