diff --git a/common/changes/office-ui-fabric-react/dropdown-onchange_2019-03-29-18-15.json b/common/changes/office-ui-fabric-react/dropdown-onchange_2019-03-29-18-15.json new file mode 100644 index 0000000000000..085380965627b --- /dev/null +++ b/common/changes/office-ui-fabric-react/dropdown-onchange_2019-03-29-18-15.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "packageName": "office-ui-fabric-react", + "comment": "Dropdown: The `onChange` callback's event target should always be the dropdown element, which contains the id attribute passed in through props.", + "type": "patch" + } + ], + "packageName": "office-ui-fabric-react", + "email": "dzearing@microsoft.com" +} diff --git a/packages/office-ui-fabric-react/src/components/Dropdown/Dropdown.base.tsx b/packages/office-ui-fabric-react/src/components/Dropdown/Dropdown.base.tsx index 02f3730a8f2f9..9c4de252280b1 100644 --- a/packages/office-ui-fabric-react/src/components/Dropdown/Dropdown.base.tsx +++ b/packages/office-ui-fabric-react/src/components/Dropdown/Dropdown.base.tsx @@ -330,7 +330,8 @@ export class DropdownBase extends BaseComponent { const onChangeSpy = jest.fn(); try { - ReactDOM.render(, container); + ReactDOM.render( + , + container + ); dropdownRoot = container.querySelector('.ms-Dropdown') as HTMLElement; ReactTestUtils.Simulate.click(dropdownRoot); @@ -171,6 +174,7 @@ describe('Dropdown', () => { ReactTestUtils.Simulate.click(secondItemElement); } finally { expect(onChangeSpy).toHaveBeenCalledWith(expect.anything(), DEFAULT_OPTIONS[2], 2); + expect(onChangeSpy.mock.calls[0][0].target.id).toEqual('foo'); } });