Closed afzaalahmad closed 1 year ago
Hello Afzaal,
This is not supported by our Input component, it would be great if you shared with us what is your use-case?
Hi @taheramr, I am using a hook called usePhoneInput
from react-international-phone
to format the phone. This library requires the original onChange input event as a parameter in handlePhoneChangeValue
method coming from the hook.
Library owner is using preventDefault
, inputType
from event.nativeEvent
, selectionStart
from event.target
and setSelectionRange
from inputRef.
If we can export these, it'd be enough for my use-case. But my opinion is that originalEvent should be available.
@taheramr I can see that cloudscape team have suppressed events in onChange, onBlur and other event callbacks
which doesn't make any sense to me because event callbacks are listeners and data flow is outward. Either I am missing something where you suggested that events can be misused and abused. But my point is that you are neither ejecting original events in events callback nor in inputRef. So, as a user, let's say that it is very critical for me to get the originalEvent for many other purposes. Now you've suppressed the events in the library but that doesn't mean that you can stop me as a user to get the event. I can use the very bad approach of getting the element using window.getElementById
and put an addEventListener
on it in useEffect. So, by wrapping up and suppressing the events, you are forcing a legit and good user to use sub-standard techniques and bad workarounds to get the task done.
IMO, whole orignal event should be available as a second argument in onChange, and onBlur.
As of now we are not supporting the original event to be passed down through the onChange
and onBlur
events.
What I'm hearing from your request is that the external library is basically masking the input to handle phone input types.
If you want to render a Cloudscape-styled phone input, use your own styles with addition of our design tokens.
The comment above contains our latest recommendation.
We have no plans of exposing native events through our API, because it would expose unwanted implementation details. No more actions on our end, resolving
Browser
Chrome, Safari, Firefox, Edge
Package version
v3.0.302
React version
v18
Description
I need original event from input onChange and onBlur and other events to modify the formatting of input but I don't have originalEvent available in onChange of Input component.
Source code
No response
Reproduction
No response
Code of Conduct