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
Datepicker: Trigger "input" event after select date #2081
base: main
Are you sure you want to change the base?
Conversation
|
Hey @worpet , thanks for the contribution! Can you explain why this would be needed? It would definitely need tests though. |
Triggering the "input" event is needed for the same reason it currently triggers the "change" event: because the contents of the input have changed and anything watching that input for changes should be notified. There are interoperability problems without this. For example, we are working with a system that watches all form inputs for changes via each of their "input" events. Using the Datepicker, it has created a situation where the input it is attached to does not trigger the "input" event after its value has changed via a date being chosen. Is there currently a test testing that |
@worpet Thanks for the input! To me, this change sounds legit but I'm unsure if this will breaks stuff for people. Regarding tests, take a look here: https://github.com/jquery/jquery-ui/blob/main/tests/unit/datepicker/events.js#L29 @mgol What do you thin about this? |
Is this a jQuery-based system? Triggering an |
@dmethvin Yes, it is primarily a jQuery system. I understand that jQuery UI stopped active development before this event became widely supported. In jQuery core, the "input" event is supported the same as any other event (you can add listeners for it or trigger it). We are using the Datepicker as a convenient way to add a calendar to relevant inputs. It works well, except it does not trigger the "input" event after changing the input's value. I understand if you're not interested in adding this, but it seemed like an easy and straightforward change that can extend the useful life of Datepicker. |
@worpet I am trying to understand the situation. If we determine a way to do this without changes to jQuery UI then you can use the current version and don't need to wait for a new release. Is this a blocker to your work? What are you doing at the moment? If the other parts of the system are jQuery it seems like you could use the |
@fnagel You marked it as Behavior Change; do you consider it requiring a minor version bump? @dmethvin In many cases it's probably the easiest to just listen for the @worpet In general, semantics of the input & change event are different; |
@mgol Adding an event looks like a change that could break things for people. So a minor release would be a good thing in theory. Not sure if it's worth the wait though. |
@dmethvin Our workaround is to use Datepicker's "onSelect" option to fire the "input" event, since that is when the calendar's value is synced to the input's value. So this change is not critical for us, but I thought I would try contributing since it would be nice if it worked out of the box. @mgol This is a good point that adding "input" to only Datepicker may make it inconsistent with the other widgets that remain without it. |
The jQuery UI codebase seems largely unaware of the In many cases, adding support for the It might be fine to do this change just for the datepicker; folks interested in other widgets could submit separate PRs. What do you think, @fnagel? @worpet before we can accept a PR, it would still need tests. |
@mgol I'm against changing this for Datepicker only, making it the only widget triggering the input event. I would like to keep a little consistency here. I'm fine with a PR changing it for all, but this seems a more complex task. As @worpet mentioned, the workaround here is pretty straight forward, so I'm more likely to vote against this PR. Sorry @worpet :-( |
@fnagel OK, makes sense, thanks for your input. |
This is a small change to fix #2078. The input's "input" event is triggered in addition to the "change" event.