feat: add mode to disable on click until response is handled - #10030
Open
sissbruecker wants to merge 4 commits into
Open
feat: add mode to disable on click until response is handled#10030sissbruecker wants to merge 4 commits into
sissbruecker wants to merge 4 commits into
Conversation
Adds DisableOnClickMode with UNTIL_ENABLED (existing behavior, default) and UNTIL_RESPONSE, which enables the button again before the response is sent so accidental extra clicks are blocked without re-enabling it manually. Related to #1553. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Flow drops a beforeClientResponse action if the component is not attached to the same UI when the response is sent, so the enable scheduled by UNTIL_RESPONSE was lost when a click listener detached the component and it was later attached to another UI, for example after a reload with @PreserveOnRefresh. Register the actions on every attach instead. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
vaadin-review-bot
left a comment
Collaborator
There was a problem hiding this comment.
✅ Nothing to flag — the changes look good.
|
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.



Description
Closes #1553
PR explanation
Disable on click protects against accidental double clicks, but until now the button stayed disabled until the application enabled it again from a click listener. For the common case, where the button should only be blocked while the server handles the click, that meant extra code in every listener. This adds a mode where the button is enabled again automatically once the click has been handled, so preventing double submits becomes a one-liner.
DisableOnClickModewith two modes for how long a button stays disabled after it was disabled on clickUNTIL_ENABLEDis the existing behavior and the default: the button stays disabled until the application enables it againUNTIL_RESPONSEenables the button again automatically once the click has been handled, with the response to the clickButton.setDisableOnClick(DisableOnClickMode)andButton.getDisableOnClickMode()UNTIL_RESPONSEmode, a click listener can still decide the final state by callingsetEnabled(true)orsetEnabled(false), in which case the automatic enabling is skipped for that click@PreserveOnRefreshUNTIL_RESPONSEType of change
Note
UNTIL_RESPONSEenables the button with the next response the server sends after the click. If a click listener callsUI.push()while it is still running, that push is the next response and enables the button before the listener has finished. This is documented on the enum constant.