Saved
Lessons learned:
- The original example has state strewn throughout the code. Using a framework helps organize these.
- I was surprised to find that once the AlertDialog is closed it returns focus to the textarea, not to the element that triggered it. This might seem like a better UX but goes against my initial inclination of returning focus to the button that triggered it to follow the same path that got the user there.
- The keyboard-related Utils use
keyCode
which is deprecated. I usedkey
instead. - Svelte has a really cool
<svelte:body />
component that I thought would make it easy to apply a class conditionally through a class directive, eg<svelte:body class:has-dialog={true} />
, but that is not yet currently supported. See sveltejs/svelte#3105 on GitHub for more info.