|
38 | 38 |
|
39 | 39 | import com.vaadin.flow.component.ComponentUtil; |
40 | 40 | import com.vaadin.flow.component.UI; |
| 41 | +import com.vaadin.flow.component.internal.PendingJavaScriptInvocation; |
41 | 42 | import com.vaadin.flow.function.SerializableConsumer; |
42 | 43 | import com.vaadin.flow.internal.StateTree.BeforeClientResponseEntry; |
43 | 44 | import com.vaadin.flow.internal.StateTree.ExecutionRegistration; |
44 | 45 | import com.vaadin.flow.internal.change.NodeAttachChange; |
45 | 46 | import com.vaadin.flow.internal.change.NodeChange; |
46 | 47 | import com.vaadin.flow.internal.change.NodeDetachChange; |
| 48 | +import com.vaadin.flow.internal.nodefeature.ElementData; |
47 | 49 | import com.vaadin.flow.internal.nodefeature.InertData; |
48 | 50 | import com.vaadin.flow.internal.nodefeature.NodeFeature; |
49 | 51 | import com.vaadin.flow.internal.nodefeature.NodeFeatureRegistry; |
@@ -632,6 +634,15 @@ public void collectChanges(Consumer<NodeChange> collector) { |
632 | 634 | if (!isAttached()) { |
633 | 635 | return; |
634 | 636 | } |
| 637 | + |
| 638 | + if (isInitialChanges && !isVisible()) { |
| 639 | + if (hasFeature(ElementData.class)) { |
| 640 | + doCollectChanges(collector, |
| 641 | + Stream.of(getFeature(ElementData.class))); |
| 642 | + } |
| 643 | + return; |
| 644 | + } |
| 645 | + |
635 | 646 | if (isInactive()) { |
636 | 647 | if (isInitialChanges) { |
637 | 648 | // send only required (reported) features updates |
@@ -956,6 +967,25 @@ public boolean isInactive() { |
956 | 967 | return getParent().isInactive(); |
957 | 968 | } |
958 | 969 |
|
| 970 | + /** |
| 971 | + * Checks (recursively towards the parent node) whether the node is |
| 972 | + * effectively visible. |
| 973 | + * <p> |
| 974 | + * Non-visible node should not participate in any RPC communication. |
| 975 | + * |
| 976 | + * @return {@code true} if the node is effectively visible |
| 977 | + */ |
| 978 | + public boolean isVisible() { |
| 979 | + if (hasFeature(ElementData.class)) { |
| 980 | + boolean isVisibleSelf = getFeature(ElementData.class).isVisible(); |
| 981 | + if (!isVisibleSelf || getParent() == null) { |
| 982 | + return isVisibleSelf; |
| 983 | + } |
| 984 | + return parent.isVisible(); |
| 985 | + } |
| 986 | + return getParent() == null || parent.isVisible(); |
| 987 | + } |
| 988 | + |
959 | 989 | /** |
960 | 990 | * Returns whether or not this state node is inert and it should not receive |
961 | 991 | * any updates from the client side. Inert state is inherited from parent, |
|
0 commit comments