Post

Your prompt: "Add a modal that smoothly slides into view and fades out when closed." Unguided coding agent: Custom <div>, z-index: 9999, and JS setTimeout unmount hacks. Guided coding agent: Native <dialog> with @starting-style, overlay, and allow-discrete transitions.

0 reposts11 likes

@rviscomi.dev am I right that the "unguided agent" has produced a modal that animates in & out in all browsers, but with the power of Google's Modern Web Guidance it has used a pattern that only animated out in Chrome?

This was my experience. I literally did that a few days ago. The initial version it produced works only on Google Chrome, and only after telling agent that it is not behaving the same in FF and Safari it added TONNES of fallbacks here and there.

Thanks for sharing, that's definitely an issue! Can I ask how you installed modern web guidance? Wondering if you're on a version without the fix, you may need to manually update

Yes, we had a bug in the guidance at the time this video was recorded a few weeks ago, but it has since been fixed. I also noticed the bug in the video yesterday and requested a correction, which should be coming soon. But thanks for pointing it out.

Yes, I found and fixed the bug in the guidance but didn't connect the dots with the video someone else on my team had already recorded until it was already published. My mistake.

The native dialog version is also easier to check by hand. A quick pass for Escape to close and focus returning to the trigger tends to expose the gaps in div-and-setTimeout versions.

Correction: since this video was recorded, MWG has been updated to improve cross-browser compatibility. allow-discrete shouldn't be used in the transition shorthand; set it separately in transition-behavior so older browsers don't drop the whole transition.

I drafted the text above yesterday, and re-reading it now I should have said "unsupported browsers" rather than "older browsers" 💙