Closed mafredri closed 1 year ago
@mafredri Good feedback, I like it, thanks! 😄 I will try to capture some of these.
I did a little investigation regarding 1., the reason raise()
might not be working in this use-case is that it (raise) does not consider the modal the focused window. Instead it raises the windows behind the window that was focused before I triggered the modal. Interestingly Window.focused()
does consider the modal the focused window, so there seems to be a little mis-match in behavior between the two.
Great feedback! 🚀 I did the following:
Modal#focus()
to focus the modal and make it the key window to receive events (552d93c)textDidCommit
for callback function when the input modal’s text field is committed, this will capture return, tab and backtab (a5d0315)didResize
for callback function when the modal resizes. Also bound it to the origin function when building a modal to reposition automatically (65b886a).
I tried re-implementing one of my old experiments with the new input modals and found a few shortcomings for that use-case. Even so, I really like what you did with them, nice job!
Here are my findings:
window.focus()
without losing modal focus. Essentially an API likewindow.raise()
but more reliable "raise to top" behavior (see demo using.focus()
). Thewindow.raise()
API often doesn't bring a window all the way up.Window.focused()
after the modal is created, but it's brittle (how do we know it's our input modal vs another modal?) and swapping focus between windows quickly is not very reliable and keyboard input can be leaked to the other window during focus swapsescape
,return
,tab
,shift+tab
), it'd be nice to be able to handle these keys via modal input instead of assigning new key handlers that are disassociated from the modal. If modal loses focus, pressing Enter in another application still causes an action in the modal unless we also start tracking state ofwindowDidFocus
(results in a lot of state handling between windows and key handlers).dark
and macOS Light does not differentiate significantly from the non-placeholder text, the above could helporigin
function inModal.build
does not propagate to future modal updates which limits its usefulness, it'd be nice if setting an icon on the modal or updating the text could re-trigger the origin function so it becomes e.g. centeredWindow.all({visible: true})
during modal show can result in a janky animation (freezes halfway through), it can also prevent keyboard input until the action completes. I understand this is because JS is all running on the same thread, but is there any opportunities for improvement here? Could we use a Promise based API for functions likeWindow.all()
that can run on a separate thread? Or introduce aPhoenix.thread(() => Window.all())
wrapper? Or maybe just run the input modal on a separate thread, resulting in a lot of calls totextDidChange
once the blocker is gone? Ideally these APIs wouldn't even be slow in the first place, but since we're at the mercy of app developers..Example usage:
Example code (very much a wip):