Skip to content

Commit bb18e29

Browse files
committed
Squashed commit of the following:
commit 80dc30c Author: Adam Thompson <[email protected]> Date: Fri Aug 25 12:46:50 2023 -0400 rm lib from dev dep commit d2377e7 Merge: 3d0abb5 50a45ae Author: Adam Thompson <[email protected]> Date: Fri Aug 25 12:40:53 2023 -0400 Merge branch 'fix-button-test-next' into adam/generic-useControlledValue commit 50a45ae Author: Adam Thompson <[email protected]> Date: Fri Aug 25 12:33:53 2023 -0400 Adds NextLink legacyBehavior test commit 3d0abb5 Merge: 152db57 a579f5e Author: Adam Thompson <[email protected]> Date: Fri Aug 25 10:56:38 2023 -0400 Merge branch 'main' into adam/generic-useControlledValue commit 152db57 Author: Adam Thompson <[email protected]> Date: Fri Aug 25 10:56:05 2023 -0400 expect no console commit 405229a Author: Adam Thompson <[email protected]> Date: Fri Aug 25 10:28:40 2023 -0400 resolves circular dependency in lib commit 0fd6d6b Author: Adam Thompson <[email protected]> Date: Fri Aug 25 10:20:25 2023 -0400 Update useControlledValue.spec.tsx commit 4f37e4b Merge: f6751e8 3fe03b5 Author: Adam Thompson <[email protected]> Date: Thu Aug 24 17:10:51 2023 -0400 Merge branch 'main' into adam/generic-useControlledValue commit f6751e8 Author: Adam Thompson <[email protected]> Date: Thu Aug 24 17:10:12 2023 -0400 adds initialValue & warning commit af6cc48 Author: Adam Thompson <[email protected]> Date: Thu Aug 24 16:31:17 2023 -0400 adds synthetic events commit bbb1832 Author: Adam Thompson <[email protected]> Date: Thu Aug 24 15:51:20 2023 -0400 isControlled never changes from initial render commit f4e1c61 Author: Adam Thompson <[email protected]> Date: Thu Aug 24 15:32:55 2023 -0400 adds value tests commit b612835 Author: Adam Thompson <[email protected]> Date: Thu Aug 24 15:28:30 2023 -0400 adds test component tests commit c565f26 Author: Adam Thompson <[email protected]> Date: Thu Aug 24 15:16:06 2023 -0400 Adds more explicit tests commit eec25b7 Merge: 753ba16 fd90750 Author: Adam Thompson <[email protected]> Date: Thu Aug 24 14:55:04 2023 -0400 Merge branch 'main' into adam/generic-useControlledValue commit 753ba16 Author: Adam Thompson <[email protected]> Date: Thu Aug 24 12:49:00 2023 -0400 Extends `useControlledValue` to accept any type
1 parent f7a0d2a commit bb18e29

File tree

7 files changed

+449
-54
lines changed

7 files changed

+449
-54
lines changed

.changeset/soft-berries-obey.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@leafygreen-ui/hooks': minor
3+
---
4+
5+
- Extends `useControlledValue` to accept any type.
6+
- Adds `updateValue` function in return value. This method triggers a synthetic event to update the value of a controlled or uncontrolled component.
7+
- Adds `initialValue` argument. Used for setting the initial value for uncontrolled components. Without this we may encounter a React error for switching between controlled/uncontrolled inputs
8+
- The value of `isControlled` is now immutable after the first render

packages/button/src/Button/Button.spec.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,24 @@ describe('packages/button', () => {
146146
test(`renders a when passing in a NextJS Link wrapper`, () => {
147147
// eslint-disable-next-line react/prop-types
148148
const Linker = ({ href, children, ...props }: any) => (
149-
<NextLink href={href}>
149+
<NextLink href={href} {...props}>
150+
{children}
151+
</NextLink>
152+
);
153+
154+
const { container, button } = renderButton({
155+
href: 'https://mongodb.design',
156+
as: Linker,
157+
});
158+
159+
expect(container.querySelector('button')).not.toBeInTheDocument();
160+
expect(button.tagName.toLowerCase()).toBe('a');
161+
});
162+
163+
test(`renders a when passing in a legacy NextJS Link wrapper`, () => {
164+
// eslint-disable-next-line react/prop-types
165+
const Linker = ({ href, children, ...props }: any) => (
166+
<NextLink legacyBehavior href={href}>
150167
<a {...props}>{children}</a>
151168
</NextLink>
152169
);

packages/hooks/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"access": "public"
2323
},
2424
"dependencies": {
25+
"@leafygreen-ui/lib": "^11.0.0",
2526
"lodash": "^4.17.21"
2627
},
2728
"gitHead": "dd71a2d404218ccec2e657df9c0263dc1c15b9e0",
@@ -34,7 +35,6 @@
3435
"url": "https://jira.mongodb.org/projects/PD/summary"
3536
},
3637
"devDependencies": {
37-
"@leafygreen-ui/emotion": "^4.0.7",
38-
"@leafygreen-ui/lib": "^11.0.0"
38+
"@leafygreen-ui/emotion": "^4.0.7"
3939
}
4040
}

packages/hooks/src/useControlledValue/useControlledValue.spec.ts

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)