Skip to content

fix: pnpm-lock & typing issues#2601

Closed
wingkwong wants to merge 10 commits into
heroui-inc:v.2.3.0from
wingkwong:fix/eng-569
Closed

fix: pnpm-lock & typing issues#2601
wingkwong wants to merge 10 commits into
heroui-inc:v.2.3.0from
wingkwong:fix/eng-569

Conversation

@wingkwong
Copy link
Copy Markdown
Member

@wingkwong wingkwong commented Mar 28, 2024

Closes #

📝 Description

Current Problem:

if we remove pnpm-lock.yaml and run pnpm install again, we can see the changes introduced.

previously we couldn't reproduce some issues reported by users locally but in the build package (e.g. isRequired prop not working in radio group). Tests didn't catch the failed case as well. With the updated pnpm-lock.yaml, the issue can be reproducible & the test fails expectedly.

After updating pnpm-lock.yaml, some typings would fail causing the build to fail. This ticket is to resolve all the build issues. Failing test cases will be handled separately.

⛳️ Current behavior (updates)

Please describe the current behavior that you are modifying

🚀 New behavior

Please describe the behavior or changes this PR adds

💣 Is this a breaking change (Yes/No):

📝 Additional Information

There are two test cases failing

  1. input ref value test case: handled in refactor(input): input ref test #2613
  2. isRequired test case issue: handled in fix(radio): isRequired & missing warning message in Form #2597

@wingkwong wingkwong requested a review from jrgarciadev as a code owner March 28, 2024 04:35
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 28, 2024

🦋 Changeset detected

Latest commit: f72b3a6

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

This PR includes changesets to release 27 packages
Name Type
@nextui-org/checkbox Patch
@nextui-org/input Patch
@nextui-org/navbar Patch
@nextui-org/radio Patch
@nextui-org/select Patch
@nextui-org/use-aria-multiselect Patch
@nextui-org/use-aria-press Patch
@nextui-org/modal Patch
@nextui-org/table Patch
@nextui-org/react Patch
@nextui-org/accordion Patch
@nextui-org/autocomplete Patch
@nextui-org/popover Patch
@nextui-org/chip Patch
@nextui-org/listbox Patch
@nextui-org/menu Patch
@nextui-org/pagination Patch
@nextui-org/slider Patch
@nextui-org/switch Patch
@nextui-org/use-aria-button Patch
@nextui-org/use-aria-link Patch
@nextui-org/dropdown Patch
@nextui-org/button Patch
@nextui-org/card Patch
@nextui-org/use-aria-toggle-button Patch
@nextui-org/link Patch
@nextui-org/snippet 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
Copy Markdown

vercel Bot commented Mar 28, 2024

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

Name Status Preview Comments Updated (UTC)
nextui-storybook-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 1, 2024 3:18am

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 28, 2024

@wingkwong is attempting to deploy a commit to the NextUI Inc Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 28, 2024

Important

Auto Review Skipped

Auto reviews are disabled on base/target branches other than the default branch. Please add the base/target branch pattern to the list of additional branches to be reviewed in the settings.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository.

To trigger a single review, invoke the @coderabbitai review command.

Walkthrough

The recent updates focus on enhancing type safety and user experience across various components in a UI library. Key changes include casting errorMessage as React.ReactNode in multiple components to resolve typing issues, setting sensible defaults for component properties, and refining event handling logic in the usePress function. These improvements aim to streamline development workflows and ensure a more robust and accessible UI component library.

Changes

File(s) Summary
.changeset/wise-kangaroos-wonder.md Introduces patches for NextUI components to address typing issues.
apps/docs/.../custom-impl.ts, packages/.../input.stories.tsx Casts errorMessage as React.ReactNode in custom input implementations.
packages/components/checkbox/.../checkbox-group.tsx, packages/components/input/.../input.tsx, packages/components/input/.../textarea.tsx, packages/components/radio/.../radio-group.tsx, packages/components/select/.../select.tsx Casts errorMessage as React.ReactNode in various components.
packages/components/input/src/use-input.ts Sets default props.defaultValue to an empty string and adds autoCapitalize: undefined.
packages/components/navbar/.../use-navbar.ts Sets default isMenuOpen to false using ??.
packages/hooks/use-aria-multiselect/.../use-multiselect-state.ts Updates MultiSelectProps to include a generic type T in Validation.
packages/hooks/use-aria-press/.../index.ts Refines logic for press events, handling pointerType and event propagation.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between cf0d4e4 and d65576f.
Files selected for processing (12)
  • .changeset/wise-kangaroos-wonder.md (1 hunks)
  • apps/docs/content/components/input/custom-impl.ts (1 hunks)
  • packages/components/checkbox/src/checkbox-group.tsx (1 hunks)
  • packages/components/input/src/input.tsx (1 hunks)
  • packages/components/input/src/textarea.tsx (1 hunks)
  • packages/components/input/src/use-input.ts (2 hunks)
  • packages/components/input/stories/input.stories.tsx (1 hunks)
  • packages/components/navbar/src/use-navbar.ts (1 hunks)
  • packages/components/radio/src/radio-group.tsx (1 hunks)
  • packages/components/select/src/select.tsx (1 hunks)
  • packages/hooks/use-aria-multiselect/src/use-multiselect-state.ts (1 hunks)
  • packages/hooks/use-aria-press/src/index.ts (5 hunks)
Files skipped from review due to trivial changes (2)
  • .changeset/wise-kangaroos-wonder.md
  • packages/components/input/src/textarea.tsx
Additional comments (13)
packages/components/checkbox/src/checkbox-group.tsx (1)
  • 29-29: The change to cast errorMessage as React.ReactNode aligns with the PR's objective to fix typing issues and ensures type correctness when rendering error messages. Looks good!
packages/components/radio/src/radio-group.tsx (1)
  • 30-30: Casting errorMessage as React.ReactNode here is consistent with the PR's goal to enhance type safety. Well done!
packages/hooks/use-aria-multiselect/src/use-multiselect-state.ts (1)
  • 26-26: Adding a generic type T to the Validation property in the MultiSelectProps interface enhances type safety and flexibility. This is a positive change.
packages/components/input/src/input.tsx (1)
  • 50-50: Casting errorMessage as React.ReactNode in this context ensures type correctness and aligns with the PR's objectives. Good job!
apps/docs/content/components/input/custom-impl.ts (1)
  • 148-148: Casting errorMessage as React.ReactNode in the custom implementation of the MyInput component is consistent with the PR's goal to fix typing issues. Nicely done!
packages/components/select/src/select.tsx (1)
  • 60-60: Casting errorMessage as React.ReactNode in the Select component ensures type correctness and aligns with the PR's objectives. Looks good!
packages/components/navbar/src/use-navbar.ts (1)
  • 126-126: Explicitly setting the default value for isMenuOpen to false using the nullish coalescing operator improves clarity and predictability. This is a good practice.
packages/components/input/src/use-input.ts (2)
  • 118-118: Setting a default value for props.defaultValue to an empty string if it is undefined is a good practice for ensuring predictable behavior of input components. This enhances the component's robustness.
  • 155-155: Adding autoCapitalize: undefined to the input element configuration is a minor change. While it's not immediately clear why this specific value is chosen, it doesn't seem to introduce any issues. It might be beneficial to clarify the reasoning behind this choice for future reference.
packages/components/input/stories/input.stories.tsx (1)
  • 453-453: Casting errorMessage as React.ReactNode enhances flexibility in displaying error messages, allowing for a broader range of React nodes. This change looks good.

Ensure that all existing usages of errorMessage are reviewed to confirm compatibility with this broader type.

packages/hooks/use-aria-press/src/index.ts (3)
  • 85-112: The modifications to triggerPressStart improve the robustness of press event handling by preventing redundant or invalid event processing. These changes are well-structured and enhance the logic's clarity and effectiveness.

Consider adding comments explaining the early return conditions for isDisabled, didFirePressStart, and pointerType being null, to aid future maintainers.

  • 152-178: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [116-175]

The updates to triggerPressEnd ensure that press end events are handled correctly, only after a press start event has been fired and with a valid pointer type. The careful handling of onPressEnd, onPressChange, and onPress events, including considerations for isDisabled, enhances the component's accessibility and user experience.

Ensure comprehensive testing around these updated logic paths, particularly in scenarios where press events might be interrupted or canceled, to maintain robustness.

  • 155-175: The enhancements to triggerPressUp align with the overall improvements in press event handling, ensuring consistent and predictable behavior. The careful consideration of isDisabled and pointerType enhances the component's robustness.

Review event handling across different browsers and devices to ensure consistent behavior, especially given the nuances of pointer and touch events.

@wingkwong wingkwong mentioned this pull request Mar 30, 2024
4 tasks
@wingkwong wingkwong marked this pull request as ready for review March 31, 2024 06:02
Comment thread packages/components/checkbox/src/checkbox-group.tsx
Comment thread packages/hooks/use-aria-press/src/index.ts
@ryo-manba
Copy link
Copy Markdown
Contributor

@wingkwong @jrgarciadev

Due to our use of the caret (^) version specifier in package.json, re-installing packages after deleting pnpm-lock.yaml can unexpectedly update to the latest minor versions. This has caused issues, especially with react-aria updates that brought breaking changes in validation, which we're addressing in #2561.

Therefore, it would be helpful if we could close this PR. Thank you!

@wingkwong
Copy link
Copy Markdown
Member Author

As discussed with @ryo-manba, PR2561 would address the issues. It's better to have those changes from his PR due to some dependencies with latest react-aria changes. Therefore, I'm closing this PR.

@wingkwong wingkwong closed this Apr 1, 2024
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.

3 participants