Keyboard shortcut “command palette” modal (Hotwire-first)

4475
0

A command palette feels like a SPA feature, but you can do it Hotwire-first: place a turbo_frame_tag 'modal' in the layout and load the palette HTML into it. A small Stimulus controller listens for meta+k and navigates the modal frame to /palette. The palette is just a server-rendered form; submitting it can redirect to the selected URL. This keeps the UI accessible and doesn’t require client-side routing. It also reduces build complexity: no React just for a command palette. The key is to keep the controller careful about focus and not intercept keystrokes in text inputs. I also support Esc to close by navigating the modal frame back to blank.