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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
textInput()
,textAreaInput()
,numericInput()
,passwordInput()
: allow updating value on blur #4183base: main
Are you sure you want to change the base?
textInput()
,textAreaInput()
,numericInput()
,passwordInput()
: allow updating value on blur #4183Changes from 10 commits
1219174
f27358c
170561a
9adf3c8
c93cb23
24668e3
372ab8f
3642080
a06d61a
37eda6f
0f0e4e5
085f104
8977a82
c9ba5f5
c070fe8
7ba1897
8f77bca
c907a58
d322976
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For
NumberInputBinding
, thischange
event can get triggered:updateNumericInput()
on the serverWhen we enable the option, we'll want the callback to be invoked when receiving the server message, but not when the up/down arrow event causes it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I handled this in 0f0e4e5 by adding extra data to the change event emitted by the
.receiveMessage()
method, whose presence signals that the origin of the event was a server-side message. Then, whenupdateOn === "blur"
, we ignore change events that aren't server driven.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing that's worth considering is the possibility that someone would trigger a
change
event on a programmatically via JS, like if they use shinyjs. RequiringfromServer: true
could make that stop working.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point; I'll think about this some more
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! I came up with an elegant solution (in d322976): rather than using the event data, we'll just ignore any change events that happen when the element has focus. It's unlikely that programmatic changes will happen while an element has focus, so in most cases the update is immediate. But if the changed input currently has focus, we'll just update on blur like we otherwise would.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh great! That’s much nicer than the other solutions.