Closed anithegregorian closed 11 months ago
Hi @anithegregorian,
Thank you for this request and the explanation of the background context! One question please, before I forward this further:
The current "change" event of StepInput fires when the input operation has finished. So a new "input" event would be fired at each keystroke, even before the input operation has finished.
So the issue is that Django needs an earlier notification (earlier than the current "change" event) or that Django expects the event to be named as "input"?
Sorry of the question sounds stupid, I just need to ensure I understood the issue before forwarding to the team.
Thanks, Diana
Hi @kineticjs ,
It's exactly what MDN documentation says:
For elements with type=checkbox or type=radio, the input event should fire whenever a user toggles the control, per the HTML Living Standard specification. However, historically this has not always been the case. Check compatibility, or use the change event instead for elements of these types.
A change event should fire when the element loses focus after its value was changed: for elements where the user's interaction is typing rather than selection, such as a
More on the change event over here -> https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event
One more distinction is it's not related to Django but the Django-Unicorn framework which forms a bridge between Django/Front-end browsers to allow usage of components with state management and reactivity using Morphdom. The order of events is still blurry to me, depending on what is preferable for an input element that has contenteditable
enabled.
I hope that explains your question...
Hi @anithegregorian,
Thank you for this request and the explanation of the background context! One question please, before I forward this further:
The current "change" event of StepInput fires when the input operation has finished. So a new "input" event would be fired at each keystroke, even before the input operation has finished.
So the issue is that Django needs an earlier notification (earlier than the current "change" event) or that Django expects the event to be named as "input"?
Sorry of the question sounds stupid, I just need to ensure I understood the issue before forwarding to the team.
Thanks, Diana
Hello @SAP/ui5-webcomponents-topic-b, please take a look of this feature request.
@Lyserg-Diethel thanks,
This peeked my interest, in the UI5 documentation for Vue integration Two Way Binding notes:
v-model binding doesn’t work for custom elements. In order to use two-way data binding, you need to bind and update the value yourself like this:
<ui5-input :value="inputValue" @input="inputValue = $event.target.value"></ui5-input>
If all the UI5 inputs (like input, checkbox, radios, step input, etc) components emit standard HTML5 input/change
events, maybe the two bindings could work without patching Vue code.
Even Vue model documentation suggests that. It's a hunch, haven't tested it!
Hello @anithegregorian ,
We have the same request and we plan to work on it: https://github.com/SAP/ui5-webcomponents/issues/5177
You can follow the development in the refered issue.
Best Regards, Tsanislav
Description
It may sound outlandish, however, I faced a real-world issue when using UI5 with Django and Django-Unicorn. Django-Unicorn is what LiveWire, HTMx, Stimulus or Hotwire is for Laravel and RoR. Unicorn is based on a light-weight library called MorphDom
I went down this rabbit hole to explore a hybrid solution that doesn't involve running a frontend in Node and backend in Django. After exploring several web component libraries like IBM Carbon, Google Material Design, Eva, Fluent, and Ant design system, UI5 was the best fit for my use case, its excellent for building and scaling enterprise-level web apps, has good documentation, above all, it was the easiest to install and configure with Vite. Thanks to the team at UI5 :)
The Rabbit Hole
Django-unicorn has two way bindings with a model, expressively with a Python
list
,dictionary
orQuerySet
. The problem with UI5 StepInput is it doesn't emit aninput
event, so this one fails when binding it with a list model:Same with a
ui5-input
works flawlessly because it emits aninput
event:The reason for this failure is that Django-unicorn directive
unicorn:model
binds to some specific input events, although some modifiers make it less painful eg.lazy
,debounce
anddefer
.A temporary fix
I was able to pull out the
@ui5/webcomponents/dist/StepInput.js
file and patch it somehow to emit aninput
event with thechange
event which is sort of hackish:It would be great to have some of the basic input events emitted from UI5 web components, lest it's an architectural/design system constraint.