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 FormCheckbox erroring when an "integer-like" key is used #2801

Merged

Conversation

Exanite
Copy link
Contributor

@Exanite Exanite commented Sep 8, 2023

This fixes #2799.

@vercel
Copy link

vercel bot commented Sep 8, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
ariakit ✅ Ready (Inspect) Visit Preview Sep 9, 2023 1:45am
1 Ignored Deployment
Name Status Preview Updated (UTC)
reakit ⬜️ Ignored (Inspect) Visit Preview Sep 9, 2023 1:45am

@changeset-bot
Copy link

changeset-bot bot commented Sep 8, 2023

🦋 Changeset detected

Latest commit: 7511985

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@ariakit/core Patch
@ariakit/react-core Patch
@ariakit/react Patch
@ariakit/test Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Sep 8, 2023

@Exanite is attempting to deploy a commit to the Ariakit Team on Vercel.

A member of the Team first needs to authorize it.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Sep 8, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 7511985:

Sandbox Source
Ariakit Configuration

@@ -57,9 +53,9 @@ export function get<T>(
return defaultValue as T;
}
if (!rest.length) {
return values[key] ?? defaultValue;
return (values[key] ?? defaultValue) as T;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if using the type assertions here is a good idea, but it doesn't affect functionality and there's no way to verify that the returned value is actually T.

Copy link
Member

@diegohaz diegohaz left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, @Exanite!

Would you mind creating a basic example (without a readme.md file) that illustrates your use case along with some tests? This will prevent future regressions.

import type { DeepMap, DeepPartial, Names, StringLike } from "./types.js";

type Values = AnyObject;
type Values = Record<string, unknown>;
Copy link
Member

Choose a reason for hiding this comment

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

I'm thinking now that this could represent a breaking change since this Values type is exposed as FormStoreValues below.

We can do that in a separate PR, but it's probably safer for this PR to just include the Array.isArray fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I'll remove these changes from my PR.

@diegohaz diegohaz enabled auto-merge (squash) September 9, 2023 01:38
@diegohaz diegohaz merged commit 887b08f into ariakit:main Sep 9, 2023
14 checks passed
@github-actions github-actions bot mentioned this pull request Sep 9, 2023
@Exanite Exanite deleted the fix/form-checkbox-integer-like-field-names branch September 10, 2023 03:55
diegohaz pushed a commit that referenced this pull request Sep 10, 2023
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @ariakit/core@0.3.1

### Patch Changes

- [`#2801`](#2801) Fixed
`values.slice` error that would occur when clicking on `FormCheckbox`
that uses an integer-like field name.

## @ariakit/react@0.3.1

### Patch Changes

- [`#2804`](#2804) New in this
version: [**Component
providers**](https://ariakit.org/guide/component-providers)

Component providers are optional components that act as a higher-level
API on top of [component
stores](https://ariakit.org/guide/component-stores). They wrap Ariakit
components and automatically provide a store to them.

- [`#2797`](#2797) Fixed a
regression on `Dialog` regarding the timing of its "focus on hide"
behavior.

- [`#2801`](#2801) Fixed
`values.slice` error that would occur when clicking on `FormCheckbox`
that uses an integer-like field name.

- [`#2802`](#2802) Added
`setMounted` prop to `useDisclosureStore` and derived component stores.
This callback prop can be used to react to changes in the `mounted`
state. For example:

    ```js
    useDialogStore({
      setMounted(mounted) {
        if (!mounted) {
          props.onUnmount?.();
        }
      },
    });
    ```

- [`#2803`](#2803) The `Toolbar`
component can now render without needing an explicit `store` prop or a
`ToolbarProvider` component wrap. `Toolbar` now also supports certain
store props such as `focusLoop`, `orientation`, `rtl`, and
`virtualFocus`.

-   Updated dependencies: `@ariakit/react-core@0.3.1`.

## @ariakit/react-core@0.3.1

### Patch Changes

- [`#2797`](#2797) Fixed a
regression on `Dialog` regarding the timing of its "focus on hide"
behavior.

- [`#2801`](#2801) Fixed
`values.slice` error that would occur when clicking on `FormCheckbox`
that uses an integer-like field name.

- [`#2802`](#2802) Added
`setMounted` prop to `useDisclosureStore` and derived component stores.
This callback prop can be used to react to changes in the `mounted`
state. For example:

    ```js
    useDialogStore({
      setMounted(mounted) {
        if (!mounted) {
          props.onUnmount?.();
        }
      },
    });
    ```

- [`#2803`](#2803) The `Toolbar`
component can now render without needing an explicit `store` prop or a
`ToolbarProvider` component wrap. `Toolbar` now also supports certain
store props such as `focusLoop`, `orientation`, `rtl`, and
`virtualFocus`.

-   Updated dependencies: `@ariakit/core@0.3.1`.

## @ariakit/test@0.2.4

### Patch Changes

-   Updated dependencies: `@ariakit/core@0.3.1`.

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FormCheckbox errors when an "integer-like" name is used as a field name
2 participants