Fluentui: TextField `onChange` handler does not forward the `event`

Created on 29 Jun 2018  路  3Comments  路  Source: microsoft/fluentui

If I want a single onChange event handler for multiple TextField components, I am unable to determine which component triggered the event since the only argument is the value

This creates a black box that requires the developer to create multiple handlers or bound handlers to determine trivial info about the event. Also, this prevents the developer from using event.preventDefault(). Furthermore, it does not make a distinction between onInput and onChange which are fundamentally unique and mutually exclusive.

TextField Needs

Most helpful comment

Yeah, not great! This should be fixed as soon as possible.

Recommendations;

Add onChange(ev: HTMLInputEvent, value: val), which lets you handle ev, and provides the current value if you want it.

Mark onChanged as deprecated. Keep it backwards compatible to avoid breaking partners.

All 3 comments

This is funny.

They added onChanged to get only the values when it changes (onChange/onInput don't work), but if you put onKeyUp you can register the event.

I mean, Why did they bind the onKeyUp event to the input but no the onChange/onInput?

It just doesn't make sense. I kind guess that is happening to resolve the onChanged event but it would be ok if that event sends the event too.

Note the link above is now broken, here is a working link from Git history and here is the current location of said code.

Yeah, not great! This should be fixed as soon as possible.

Recommendations;

Add onChange(ev: HTMLInputEvent, value: val), which lets you handle ev, and provides the current value if you want it.

Mark onChanged as deprecated. Keep it backwards compatible to avoid breaking partners.

Was this page helpful?
0 / 5 - 0 ratings