jt_loves_tacos
New Member
- Messages
- 75
- Reaction score
- 0
- Location
- Phoenix, AZ
Been rebuilding a settings modal at work and decided to finally use the native <dialog> element instead of another div soup overlay. Weirdly painless for the basic open/close stuff. showModal() handles focus trapping and Esc for me, and forms with method='dialog' close automatically. Felt like cheating after years of hacking z-index and focus traps.
But then iOS Safari did the usual thing. Backdrop blur looked fine on desktop, then on my phone the dialog got tucked under the keyboard when an input got focused. Had to add scroll padding and a resize listener. Also the default ::backdrop styling gets weird in older Safari unless you target it directly, which took me way too long to figure out.
Not saying I'm going back to custom modals, but I get why some teams wait. Anyone using <dialog> on a real project with forms? Did you hit the keyboard thing too? Curious if there's a cleaner fix than my janky JS bandaid.