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

Components: refactor BorderControl to pass exhaustive-deps #41259

Merged
merged 3 commits into from
May 24, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Internal

- `AlignmentMatrixControl` updated to satisfy `react/exhuastive-deps` eslint rule ([#41167](https://github.com/WordPress/gutenberg/pull/41167))
- `BorderControl` updated to satisfy `react/exhuastive-deps` eslint rule ([#41259](https://github.com/WordPress/gutenberg/pull/41259))
- `CheckboxControl`: Add unit tests ([#41165](https://github.com/WordPress/gutenberg/pull/41165)).

## 19.11.0 (2022-05-18)
Expand Down
10 changes: 8 additions & 2 deletions packages/components/src/border-control/border-control/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function useBorderControl(

onChange( newBorder );
},
[ onChange, shouldSanitizeBorder, sanitizeBorder ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aaronrobertshaw , do you remember if there's any particular reason why you added sanitizeBorder to the list of dependencies here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Honestly can't recall and looks like I added it before tidying up local experimentation and drafting the initial PR.

I probably just had it in my head that changing sanitizeBorder would mean a changed callback. It makes sense that coming from an outer scope it isn't a valid dependency and should be removed.

[ onChange, shouldSanitizeBorder ]
);

const onWidthChange = useCallback(
Expand Down Expand Up @@ -97,7 +97,13 @@ export function useBorderControl(

onBorderChange( updatedBorder );
},
[ border, hadPreviousZeroWidth, onBorderChange ]
[
border,
hadPreviousZeroWidth,
colorSelection,
styleSelection,
onBorderChange,
]
);

const onSliderChange = useCallback(
Expand Down