Skip to content

docs: broaden Element bindProperty revert behavior - #6753

Merged
peholmst merged 3 commits into
mainfrom
doc-bot/vaadin-flow/26966-53b232460adfe3b6
Dec 2, 2026
Merged

peholmst merged 3 commits into
mainfrom
doc-bot/vaadin-flow/26966-53b232460adfe3b6

Conversation

@vaadin-bot

@vaadin-bot vaadin-bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Documentation for vaadin/flow#26966 by @totally-not-ai[bot].

Note

The source pull request is merged, so this documentation describes the final
shape of the change. Please review it and mark it ready for review.

Change categories: BEHAVIOR_CHANGE

File Change
articles/flow/ui-state/element-bindings.adoc Broadens the Element#bindProperty() revert description: the client-side property reverts whenever the signal's value differs from the value the client sent after the write callback runs (type mismatch, a validating callback that leaves the signal unchanged, or a callback that writes a different value). A property change event fires only when the callback wrote a different value. The callback must update the signal synchronously; with an asynchronous update the client first reverts, then receives the new value.

Auto-generated by the Documentation Bot — review before merging.

Generated by Documentation Bot for #26966 · agent · 97.1 AIC · ⊞ 11.7K · ◷

  • expires on Dec 23, 2026, 2:20 PM UTC

@github-actions

Copy link
Copy Markdown
Contributor

Preview Deployment

This PR has been deployed for preview.

URL: https://docs-preview-pr-6753.fly.dev

Changed pages

Added content is highlighted in green; removed content is marked in red on each page.

Built from 87524ec

@peholmst
peholmst marked this pull request as ready for review December 2, 2026 07:44

@vaadin-review-bot vaadin-review-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the changes — left 2 comments.

Finding
⚠️ The claim about an asynchronous write callback is inverted: the client value is reverted, not kept
⚠️ "no property change event firing for the revert" is true only when the callback leaves the signal unchanged

[since:com.vaadin:vaadin@V25.3]#A value that arrives from the client isn't guaranteed to have the type of the bound signal -- the client is free to set a property to anything. A value the signal can't hold is rejected: a warning is logged, and the property is reverted on the client to the value the signal holds. The write callback isn't expected to handle this itself, so a binding needs no defensive code for it.#
[since:com.vaadin:vaadin@V25.3]#A value that arrives from the client isn't guaranteed to have the type of the bound signal -- the client is free to set a property to anything. A value the signal can't hold is rejected: a warning is logged. The write callback isn't expected to handle this itself, so a binding needs no defensive code for it.#

The write callback must update the signal synchronously. After the callback returns, the signal's value is compared to the value the client sent. If they differ -- whether because the value didn't match the signal's type, because a validating callback left the signal unchanged, or for any other reason -- the property is reverted on the client to the value the signal holds, with no property change event firing for the revert. A callback that updates the signal asynchronously leaves the client showing its own value until the signal changes.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ The claim about an asynchronous write callback is inverted: the client value is reverted, not kept

"A callback that updates the signal asynchronously leaves the client showing its own value until the signal changes."

The opposite happens, and the preceding sentence in the same paragraph already says so. When the callback returns without having changed the signal, the signal value differs from the client value, so Flow queues the signal value for the client (ElementPropertyMap.doDeferredUpdateFromClient, lines 694-701, and the test bindProperty_noOpCallback_noEventAndSignalValueSentToClient: "The client shows "bar", so it has to be told to go back to "foo""). The Element#bindProperty javadoc states it too: "a client-side value is reverted to the current signal value until the signal changes" (Element.java:1035-1037).

Suggested rewrite: "A callback that updates the signal asynchronously makes the client revert to the signal's current value, and the asynchronous update reaches the client only once it changes the signal."

element-bindings.adoc:113 · accuracy

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. The page now says that a callback that updates the signal asynchronously makes the client revert to the signal's current value, and that the client receives the new value once the asynchronous update changes the signal.

[since:com.vaadin:vaadin@V25.3]#A value that arrives from the client isn't guaranteed to have the type of the bound signal -- the client is free to set a property to anything. A value the signal can't hold is rejected: a warning is logged, and the property is reverted on the client to the value the signal holds. The write callback isn't expected to handle this itself, so a binding needs no defensive code for it.#
[since:com.vaadin:vaadin@V25.3]#A value that arrives from the client isn't guaranteed to have the type of the bound signal -- the client is free to set a property to anything. A value the signal can't hold is rejected: a warning is logged. The write callback isn't expected to handle this itself, so a binding needs no defensive code for it.#

The write callback must update the signal synchronously. After the callback returns, the signal's value is compared to the value the client sent. If they differ -- whether because the value didn't match the signal's type, because a validating callback left the signal unchanged, or for any other reason -- the property is reverted on the client to the value the signal holds, with no property change event firing for the revert. A callback that updates the signal asynchronously leaves the client showing its own value until the signal changes.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ "no property change event firing for the revert" is true only when the callback leaves the signal unchanged

When the callback writes a different value to the signal, the property is reverted to that value and a property change event fires with it. See ElementBindPropertyTest.bindProperty_transformingCallback_valueChangeEventTriggered (line 989): a client update of "bar" with a callback that upper-cases gives eventValue == "BAR" and counter == 1. No event fires only when the signal is left unchanged, including the type-mismatch case (bindProperty_noOpCallback_noEventAndSignalValueSentToClient, line 1014).

The sibling page already draws this distinction for field bindings, in articles/flow/ui-state/building-ui.adoc:240 and :254.

Suggested rewrite: "…the property is reverted on the client to the value the signal holds. A callback that leaves the signal unchanged fires no property change event. A callback that writes a different value fires one for the value that the signal holds."

element-bindings.adoc:113 · accuracy

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. The paragraph now separates the two cases. A callback that leaves the signal unchanged fires no property change event. A callback that writes a different value fires one with the value that the signal holds. I also split the long sentence and listed that third revert case.

A callback that updates the signal asynchronously makes the client
revert to the signal value, it doesn't keep the client value. A callback
that writes a different value fires a property change event with it;
only a callback that leaves the signal unchanged fires none.
@peholmst
peholmst merged commit deaf057 into main Dec 2, 2026
10 of 11 checks passed
@peholmst
peholmst deleted the doc-bot/vaadin-flow/26966-53b232460adfe3b6 branch December 2, 2026 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants