Skip to content

Commit 94cd872

Browse files
committed
Update fluent-ui components to be backwards compatible with v7
1 parent bf5e61d commit 94cd872

File tree

8 files changed

+4196
-508
lines changed

8 files changed

+4196
-508
lines changed

packages/fluent-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"node": ">=14"
3030
},
3131
"peerDependencies": {
32-
"@fluentui/react": "^8.1.0",
32+
"@fluentui/react": ">= 7",
3333
"@rjsf/core": "5.6.x",
3434
"@rjsf/utils": "5.6.x",
3535
"react": "^16.14.0 || >=17"

packages/fluent-ui/src/CheckboxWidget/CheckboxWidget.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ export const allowedProps: (keyof ICheckboxProps)[] = [
2828
'disabled',
2929
'indeterminate',
3030
'inputProps',
31+
/* Backward compatibility with fluentui v7 */
32+
'keytipProps' as any,
3133
'label',
3234
'onChange',
3335
'onRenderLabel',
@@ -101,6 +103,12 @@ export default function CheckboxWidget<
101103
onChange={_onChange}
102104
{...uiProps}
103105
aria-describedby={ariaDescribedByIds<T>(id)}
106+
/* Backward compatibility with fluentui v7 */
107+
{...{
108+
autoFocus: autofocus,
109+
onBlur: _onBlur,
110+
onFocus: _onFocus,
111+
}}
104112
/>
105113
</>
106114
);

packages/fluent-ui/src/CheckboxesWidget/CheckboxesWidget.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ export default function CheckboxesWidget<
7979
key={index}
8080
{...uiProps}
8181
aria-describedby={ariaDescribedByIds<T>(id)}
82+
/* Backward compatibility with fluentui v7 */
83+
{...{
84+
autoFocus: autofocus && index === 0,
85+
onBlur: _onBlur,
86+
onFocus: _onFocus,
87+
}}
8288
/>
8389
);
8490
})}

packages/fluent-ui/src/RadioWidget/RadioWidget.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ const allowedProps: (keyof IChoiceGroupProps)[] = [
2020
'selectedKey',
2121
'onChange',
2222
'label',
23+
/* Backward compatibility with fluentui v7 */
24+
'onChanged' as any,
2325
'theme',
2426
'styles',
2527
'ariaLabelledBy',

packages/fluent-ui/src/UpDownWidget/UpDownWidget.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FocusEvent, SyntheticEvent } from 'react';
1+
import { ChangeEvent, FocusEvent, SyntheticEvent } from 'react';
22
import { ISpinButtonProps, SpinButton } from '@fluentui/react';
33
import {
44
ariaDescribedByIds,
@@ -29,6 +29,8 @@ const allowedProps: (keyof ISpinButtonProps)[] = [
2929
'defaultValue',
3030
'disabled',
3131
'downArrowButtonStyles',
32+
/* Backward compatibility with fluentui v7 */
33+
'getClassNames' as any,
3234
'iconButtonProps',
3335
'iconProps',
3436
'incrementButtonAriaLabel',
@@ -73,7 +75,14 @@ export default function UpDownWidget<
7375
registry,
7476
}: WidgetProps<T, S, F>) {
7577
const { translateString } = registry;
76-
const _onChange = (_: SyntheticEvent<HTMLElement>, newValue?: string) => onChange(Number(newValue));
78+
const _onChange = (ev: ChangeEvent<HTMLInputElement> | SyntheticEvent<HTMLElement>, newValue?: string) => {
79+
if (newValue) {
80+
onChange(Number(newValue));
81+
} else if ('value' in ev.target) {
82+
/* Backward compatibility with fluentui v7 */
83+
onChange(Number(ev.target.value));
84+
}
85+
};
7786

7887
let { min, max, step } = rangeSpec<S>(schema);
7988
if (min === undefined) {

0 commit comments

Comments
 (0)