Are you willing to submit a PR to fix? No
Requested priority: Normal
I have a Dropdown component and a handleChange(event, value) callback associated to the onChange event. I expect to be able to retrieve the id of the Dropdown from event.target.id in the callback, but its value changes as the selected item changes, and it's not predictable across browsers.
<Dropdown
id="myId"
placeHolder="Placeholder"
label="My label"
onChange={this.handleChange}
options={myOptions}
/>
[...]
handleChange(event, value) {
/* NB: event.target.id of events fired by a Dropdown component
* can be the id of the Dropdown component, or the
* id of one of the button tags composing the Dropdown,
* which is usually $Componentid-list$num */
const name = event.target.id.indexOf("-list") !== -1 ?
event.target.id.split("-")[0] : event.target.id;
console.log("CHANGED: " + name + ' - ', value.text);
this.setState({
[name]: value.text
});
}
In Firefox:
event.target.id can be any of these: { myId, myId-list1, myId-list2, myId-list3...}
In Chrome:
event.target.id can be any of these: { "" (empty string), myId-list1, myId-list2, myId-list3...}
event.target.id should be "myId" in every browser
See https://github.com/OfficeDev/office-ui-fabric-react/issues/54#issuecomment-391418661
related issue: https://github.com/OfficeDev/office-ui-fabric-react/issues/5744
@cliffkoh see that you are listed as the owner in our onenote.
Hi, would be great if this was fixed. Thanks!
I think I have a fix for this, testing.
:tada:This issue was addressed in #8538, which has now been successfully released as [email protected].:tada:
Handy links:
Most helpful comment
I think I have a fix for this, testing.