Closed jotaen4tinypilot closed 3 months ago
I’d see two options:
- We could revert the offending commit, because I think the focus problem is worse than the animation artifact problem. We’d have to leave an additional comment, however, since this issue is too subtle otherwise.
- We take this opportunity and refactor the initialization process of dialogs in general, so that it is unified across all dialogs, and robust against such kind of issues.
Can you share the cost estimate (in t-shirt sizing) of (2)?
Can you share the cost estimate (in t-shirt sizing) of (2)?
I’d say somewhere between “small” and “medium”. I don’t think it’s super complex, but we’d have to break it down into a few separate PRs, and also do testing in both Community and Pro separately.
I believe the work items are these:
dialog-requested
and dialog-shown
events from <overlay-panel>
component
events.js
initialize()
et al calls from app.js
dialog-shown
listener in <paste-dialog>
would resolve this issue.<overlay-panel>
component, or in events.js
gkParams
logic into dialog component itselfThat being said, we can also do (1) first, and then push (2) down the road.
Nice catch @jotaen4tinypilot! To make option (1) more appealing, since we've persisted the last masked state the original animation artifact will no longer be present/noticeable. Yay? 🥲
The persisted toggle makes the situation better indeed, though unfortunately the animation artifact is still visible when you open the paste dialog for the first time after loading the page (if the toggle was persisted as “on”).
I think the “proper” fix would still be worthwhile, because I’d find the call order of show()
and then initialize()
quite unintuitive. When you pointed out the issue in the PR, I actually thought the existing order had been incorrect in the first place. By the way, we have the same issue in the <change-hostname-dialog>
.
Let's do (1) now and hold off on (2).
Okay, I’ve opened https://github.com/tiny-pilot/tinypilot/pull/1772 to fix, and extracted https://github.com/tiny-pilot/tinypilot/issues/1773 for the general refactoring.
https://github.com/tiny-pilot/tinypilot/pull/1764 introduced a regression: the paste dialog’s
<textarea>
doesn’t receive focus anymore when opening the dialog. This is due to us switching the dialog initialization order in order to fix another problem, which is that you may see undesired UI animation artifacts while opening the dialog.The root cause is that calling
show()
afterinitialize()
renders thethis._elements.pasteArea.focus();
call irrelevant, becauseshow
also implicitly sets focus via callingshowModal()
.So right now, we’d have to decide between two problems:
.show()
before.initialize()
: users may see the animation artifact.initialize()
before.show()
: the<textarea>
doesn’t receive focusNote:
show()
is inherited from the overlay panel, whereasinitialize()
is a method from the respective dialog, e.g. in<paste-dialog>
.I’d see two options:
Considerations on general refactoring of dialog initialization
The initialization process is basically the same in all our dialogs:
.initialize()
, but that’s just an accidental inconsistency..show()
It makes sense for these two things to occur in the stated order.
Considering the amount of dialogs we have, and that they all essentially work in the same way, we could consolidate the flow, and encode a unified initialization process in the code. For example (just to illustrate the idea):
show()
could dispatch two custom events into the dialog component:dialog-requested
: the dialog may listen to that event, to carry out it’s general init procedure (if applicable)dialog-shown
: the dialog may listen to that event and do final adjustments, e.g. for setting focus (if applicable)