Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Still trigger deprecated onChanged property of Toggle #17296

Merged
merged 3 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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