Repository navigation
Conversation
|
Just a note: this could be really awesome for other use cases as well, like blocking the UI while a long running task is enqueued - e.g. pressing a button and ignoring every other client action until the server is done. |
Ok, thanks for the suggestion. I think then I'll retain the API in the |
|
Having this API inside the UI would be really good way to discover it! I wanted to mention the other use case because they probably work a little bit different like the dialog use case, as e.g. buttons aren't removed - they just finish they job. I had the following pattern in mind where no additional overlay is added vaadin/web-components#842 Naming is probably the hardest part here - still awesome addition! |
I think for this case it would be simply enough to make the UI inert and set nothing modal to it - but currently the API design in the Like the current API's javadocs says - the developer/component needs to just take care of showing a clear indication to the user that something is happening and the UI won't work - so the user won't try to do something while waiting. |
| */ | ||
| public void toggleChildModal(Component child) { | ||
| if (modalComponentStack == null) { | ||
| modalComponentStack = new Stack<>(); |
There was a problem hiding this comment.
JdkObsolete: Stack is a nonstandard class that predates the Java Collections Framework; prefer ArrayDeque. Note that the Stack methods push/pop/peek correspond to the Deque methods addFirst/removeFirst/peekFirst.
(at-me in a reply with help or ignore)
There was a problem hiding this comment.
Would make sense to use ArrayDeque.
| // cascade update to all children unless those are ignoring parent | ||
| // value or have same value and thus don't need updating. | ||
| // (all explicitly updated nodes are visited separately) | ||
| LinkedList<StateNode> stack = new LinkedList<>(); |
There was a problem hiding this comment.
JdkObsolete: It is very rare for LinkedList to out-perform ArrayList or ArrayDeque. Avoid it unless you're willing to invest a lot of time into benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does not.
(at-me in a reply with help or ignore)
There was a problem hiding this comment.
Would make sense to use ArrayDeque.
| // cascade update to all children unless those are ignoring parent | ||
| // value or have same value and thus don't need updating. | ||
| // (all explicitly updated nodes are visited separately) | ||
| LinkedList<StateNode> stack = new LinkedList<>(); |
There was a problem hiding this comment.
Would make sense to use ArrayDeque.
| */ | ||
| public void toggleChildModal(Component child) { | ||
| if (modalComponentStack == null) { | ||
| modalComponentStack = new Stack<>(); |
There was a problem hiding this comment.
Would make sense to use ArrayDeque.
| + "Add it first as a child of the UI with " | ||
| + "ui.add(component) or just use addModal(component)."); | ||
| childComponent.getParent().filter(parent -> parent == this) | ||
| .orElseThrow(illegalStateExceptionSupplier); |
There was a problem hiding this comment.
ReturnValueIgnored: Return value of 'orElseThrow' must be used (details)
(at-me in a reply with help or ignore)
3ceae7d to
940db66
Compare
Related to #7799
Also addresses an issue with stateNode.hasFeature(InertData.class) returning true for node that has no InertData.
|
SonarQube analysis reported 10 issues
|
|
SonarCloud Quality Gate failed. |
|
This ticket/PR has been released with platform 23.0.0.alpha1 and is also targeting the upcoming stable 23.0.0 version. |












Introduces the possibility to add a modal dialog to a UI in a way
that the server side will ignore interaction with all other components
(from client side) until the modal dialog is removed. Modal dialogs can
be stacked on top of each other. This is similar to setting a component disabled,
but is not the same and does not show in the UI in any way - it would be
up to the modal dialog to show a modalityy curtain on top of the outside
UI to the dialog. The feature is thus a server side security feature,
and makes the framework enforce
https://www.w3.org/TR/wai-aria-practices-1.1/#dialog_modal guidelines.
The implementation relies on a new server side only state tree feature InertData, which
makes it possible to make a component/element/statenode and its children not accept any
updates from client side, but it not the same as disabled. The inert
state is by default inherited to child nodes, except that any child can declare
itself to ignore parent inert state which means that updates are allowed for
itself and its children, unless those are explicitly made inert.
WIP:
which are TODOs in InertComponentIT
@PreserverOnRefreshis used, the inert state ofUIis still intactResolves #10172