Skip to content

Commit

Permalink
Still trigger deprecated onChanged property of Toggle (#17296)
Browse files Browse the repository at this point in the history
* Still trigger deprecated `onChanged` property of Toggle until it is removed

* Add types

* Change files
  • Loading branch information
MLoughry committed Mar 5, 2021
1 parent 73bf957 commit 5e06dfb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Still trigger deprecated `onChanged` property of Toggle until it is removed",
"packageName": "@fluentui/react",
"email": "miclo@microsoft.com",
"dependentChangeType": "patch"
}
14 changes: 13 additions & 1 deletion packages/react/src/components/Toggle/Toggle.base.tsx
Expand Up @@ -25,14 +25,26 @@ export const ToggleBase: React.FunctionComponent<IToggleProps> = React.forwardRe
// eslint-disable-next-line deprecation/deprecation
onAriaLabel,
onChange,
// eslint-disable-next-line deprecation/deprecation
onChanged,
onClick: onToggleClick,
onText,
role,
styles,
theme,
} = props;

const [checked, setChecked] = useControllableValue(controlledChecked, defaultChecked, onChange);
const [checked, setChecked] = useControllableValue(
controlledChecked,
defaultChecked,
React.useCallback(
(ev: React.MouseEvent<HTMLElement>, isChecked: boolean) => {
onChange?.(ev, isChecked);
onChanged?.(isChecked);
},
[onChange, onChanged],
),
);

const classNames = getClassNames(styles!, {
theme: theme!,
Expand Down

0 comments on commit 5e06dfb

Please sign in to comment.