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

Fix issues with SpinButton revealed by eslint-plugin-react-hooks #15431

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
3b3ba45
Updating react-internal SpinButton to handle onChange
czearing Oct 8, 2020
7bafae6
Change files
czearing Oct 8, 2020
8972505
Merge branch 'master' into feat/react-internal-spinButton-onChange
ecraig12345 Oct 23, 2020
1373550
Update change files
ecraig12345 Oct 23, 2020
d3fb423
Merge branch 'master' of https://github.com/microsoft/fluentui into f…
czearing Oct 28, 2020
289761a
Merge branch 'master' of https://github.com/microsoft/fluentui into f…
czearing Oct 29, 2020
17f60b4
Updating react-example snapshots
czearing Oct 29, 2020
e91e44b
Merge branch 'master' of https://github.com/microsoft/fluentui into f…
czearing Oct 30, 2020
ba7aed7
Building react package and updating snapshots.
czearing Oct 30, 2020
41c03ad
Merge branch 'master' into feat/react-internal-spinButton-onChange
ecraig12345 Nov 21, 2020
2018793
stateful example improvements
ecraig12345 Nov 21, 2020
ac09a83
Remove HTMLTextAreaElement from types
ecraig12345 Nov 21, 2020
89213df
temp
ecraig12345 Nov 22, 2020
73e414f
Revert onChange addition, make a few more fixes
ecraig12345 Nov 22, 2020
aedabe1
API update
ecraig12345 Nov 22, 2020
39b1b48
update change description
ecraig12345 Nov 22, 2020
5d34b68
bug fix and more tests
ecraig12345 Nov 22, 2020
3cfb925
Fix spinning by mouse and simplify updateValue signature
ecraig12345 Nov 22, 2020
25cba93
organize tests
ecraig12345 Nov 24, 2020
489f76a
Merge branch 'master' into feat/react-internal-spinButton-onChange
ecraig12345 Nov 30, 2020
34c4ff0
snapshots
ecraig12345 Nov 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "patch",
"comment": "Updating react-internal SpinButton.Stateful.Example to use onChange.",
"packageName": "@fluentui/react-examples",
"email": "czearing@outlook.com",
"dependentChangeType": "patch",
"date": "2020-10-08T18:29:11.274Z"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "minor",
"comment": "Updating react-internal SpinButton to handle onChange.",
"packageName": "@fluentui/react-internal",
"email": "czearing@outlook.com",
"dependentChangeType": "patch",
"date": "2020-10-08T18:29:41.503Z"
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,26 @@ const onSpinButtonValidate = (value: string) => {
return String(value) + suffix;
};

export const SpinButtonStatefulExample: React.FC = () => (
<div style={{ width: '400px' }}>
<SpinButton
label={'SpinButton with custom implementation:'}
min={0}
max={100}
value={'7' + suffix}
onValidate={onSpinButtonValidate}
onIncrement={onSpinButtonIncrement}
onDecrement={onSpinButtonDecrement}
incrementButtonAriaLabel={'Increase value by 2'}
decrementButtonAriaLabel={'Decrease value by 2'}
/>
</div>
);
export const SpinButtonStatefulExample: React.FC = () => {
const [spinButtonValue, setSpinButtonValue] = React.useState<string>('7' + suffix);

return (
<div style={{ width: '400px' }}>
<SpinButton
label={'SpinButton with custom implementation:'}
min={0}
max={100}
value={spinButtonValue}
onValidate={onSpinButtonValidate}
onIncrement={onSpinButtonIncrement}
onDecrement={onSpinButtonDecrement}
// eslint-disable-next-line react/jsx-no-bind
onChange={(ev: React.FormEvent<HTMLInputElement | HTMLTextAreaElement>, newValue: string): void =>
setSpinButtonValue(newValue)
}
incrementButtonAriaLabel={'Increase value by 2'}
decrementButtonAriaLabel={'Decrease value by 2'}
/>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ exports[`Component Examples renders SpinButton.Stateful.Example.tsx correctly 1`
@media screen and (-ms-high-contrast: active){&:hover:after {
border-color: Highlight;
}
onChange={[Function]}
>
<input
aria-disabled={false}
Expand Down
3 changes: 2 additions & 1 deletion packages/react-internal/etc/react-internal.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5075,7 +5075,7 @@ export interface ISpinButton {
}

// @public (undocumented)
export interface ISpinButtonProps extends React.HTMLAttributes<HTMLDivElement> {
export interface ISpinButtonProps extends React.HTMLAttributes<HTMLInputElement | HTMLTextAreaElement>, React.RefAttributes<HTMLDivElement> {
ariaDescribedBy?: string;
ariaLabel?: string;
ariaPositionInSet?: number;
Expand All @@ -5101,6 +5101,7 @@ export interface ISpinButtonProps extends React.HTMLAttributes<HTMLDivElement> {
max?: number;
min?: number;
onBlur?: React.FocusEventHandler<HTMLInputElement>;
onChange?: (ev?: React.FormEvent<HTMLInputElement | HTMLTextAreaElement>, newValue?: string) => void;
onDecrement?: (value: string, event?: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => string | void;
onFocus?: React.FocusEventHandler<HTMLInputElement>;
onIncrement?: (value: string, event?: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => string | void;
Expand Down
Loading