Repository navigation
Give notify and confirm somewhere to appear - #45
Merged
Merged
Conversation
A document can ask for two things that have no backend and no route behind them: say something to the user, and ask the user something. Every other action ends up at a host that knows how to do it, but these two are purely what the user sees, so until now a host either invented a surface or the action went to the console. The browser's own prompt was the fallback for confirm, and it is a poor one: it blocks the event loop, cannot be styled, and cannot be driven by a test. A confirm exists to gate what follows it, which makes it worth being able to assert on. The new surface asks in the page, and declining is what happens when the question is dismissed, because a gate that opens when ignored is not one. The third surface reports what this host cannot do at all. That is only useful while an application is being wired, and an application that has wired everything will never see it - but a modelled button that silently does nothing is the hardest kind of defect to trace, because nothing failed and the document is correct. It is shown rather than logged since the person who would fix it is looking at the screen. The same action is reported once however often it is asked for, so an unsupported action on an interval cannot grow until it covers the application it is describing. The three are handed out together because they are wired the same way and forgetting to render one is the failure they exist to prevent. An application with a design system of its own passes its own notify after the spread and keeps the rest. A scope's context is now optional. A document whose messages are literal text and whose actions take no arguments resolves nothing, which is an ordinary document rather than a degenerate one, and requiring a context anyway made every host invent an empty resolver - a place for a mistake to hide. Dialogs are deliberately not here. Showing one means resolving a dialog template from the application model, and nothing in React can reach the application yet. Guessing at that seam now would be harder to correct than leaving it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A document can ask for two things that have no backend and no route behind them: say something to the user, and ask the user something. Every other action ends up at a host that knows how to do it; these two are purely what the user sees, so until now a host either invented a surface or the action went to the console.
What is here
useInteractionHosts()returns thenotify,confirmandonUnsupportedparts of aBrowserDispatcherHosttogether with the surfaces that back them:They are handed out together because they are wired the same way and forgetting to render one is the failure they exist to prevent. An application with a design system of its own passes its own
notifyafter the spread and keeps the rest.Why confirm stops being a browser prompt
window.confirmblocks the event loop, cannot be styled, and cannot be driven by a test. A confirm exists to gate what follows it, which is exactly the thing worth asserting on - and the specifications here do: the command does not run until the question is answered, runs when the answer is yes, and does not when it is no. Dismissing the question declines it, because a gate that opens when ignored is not one.The unresolved-action surface
Only useful while an application is being wired, and an application that has wired everything will never see it. It exists because a modelled button that silently does nothing is the hardest kind of defect to trace: nothing failed, nothing was reported, and the document is correct. It renders rather than logs, since the person who would fix it is looking at the screen. The same action is reported once however often it is asked for, so an unsupported action on a hover or an interval cannot grow until it covers the application it is describing.
Two smaller things
InteractionScope'scontextis now optional. A document whose messages are literal text and whose actions take no arguments resolves nothing, which is an ordinary document rather than a degenerate one; requiring a context anyway made every host invent an empty resolver. Everything reading the scope still gets a context that is definitely there - only the author is spared.Writing the specifications turned up that
NotificationLevelhas three members and not four. The model, the language and its documentation all agree oninfo/warning/error, so the spec was corrected rather than the model.Not here
Dialogs. Showing one means resolving a dialog template from the application model, and nothing in React can reach the application yet - that is the
SceneApplicationProviderwork. Guessing at that seam now would be harder to correct than leaving it.Verification
yarn ciacross all eight workspaces. TwoSceneCommandFormspecifications incomponentsfail on this machine, and fail identically on a cleanmain, so they are not from this change.