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(calendar): apply inert attribute according to isHeaderExpanded #3087

Closed

Conversation

KumJungMin
Copy link
Contributor

@KumJungMin KumJungMin commented May 27, 2024

📝 Description

  • (In Firefox / develop mode) when i open datePicker, the attribute value error is occurred
스크린샷 2024-05-27 오후 12 29 29

error console

스크린샷 2024-05-27 오후 12 21 24



  • So I fixed to toggle inert attribute according to isHeaderExpanded
{...{inert: isHeaderExpanded ? "" : undefined}}

Summary by CodeRabbit

  • Refactor
    • Improved the assignment of the inert attribute in the calendar components for better code clarity and maintainability.

Copy link

changeset-bot bot commented May 27, 2024

🦋 Changeset detected

Latest commit: cd3c622

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

This PR includes changesets to release 3 packages
Name Type
@nextui-org/calendar Patch
@nextui-org/date-picker Patch
@nextui-org/react 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

Copy link

vercel bot commented May 27, 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 May 29, 2024 0:04am

Copy link

vercel bot commented May 27, 2024

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

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented May 27, 2024

Walkthrough

The changes involve updating the inert attribute assignment in the CalendarMonth and CalendarPicker components. This update replaces the previous conditional assignment with a spread syntax approach to improve code readability and maintainability.

Changes

Files Change Summary
packages/components/calendar/src/calendar-month.tsx Updated inert attribute assignment using spread syntax: inert={isHeaderExpanded ? true : undefined} to {...{inert: isHeaderExpanded ? "" : undefined}}
packages/components/calendar/src/calendar-picker.tsx Updated inert attribute assignment using spread syntax: inert={isHeaderExpanded ? true : undefined} to {...{inert: isHeaderExpanded ? "" : undefined}}

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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to full the review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @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.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
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.

Actionable comments posted: 0

Outside diff range and nitpick comments (2)
packages/components/calendar/src/calendar-month.tsx (1)

Line range hint 51-51: Using array indices as keys in React can lead to rendering issues. Consider using a more stable identifier.

- <tr key={weekIndex} ...>
+ <tr key={`week-${weekIndex}`} ...>
- <CalendarCell key={i} ...>
+ <CalendarCell key={`date-${date.toString()}`} ...>
- <th key={index} ...>
+ <th key={`day-${day}`} ...>

Also applies to: 60-60, 85-85

packages/components/calendar/src/calendar-picker.tsx (1)

Line range hint 51-51: Using array indices as keys in React can lead to rendering issues. Consider using a more stable identifier.

- <EmptyItem key={i} />
+ <EmptyItem key={`empty-item-${i}`} />

Also applies to: 55-55

Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 5194a02 and 01aa9cd.
Files selected for processing (2)
  • packages/components/calendar/src/calendar-month.tsx (1 hunks)
  • packages/components/calendar/src/calendar-picker.tsx (1 hunks)
Additional Context Used
Biome (9)
packages/components/calendar/src/calendar-month.tsx (6)

1-1: Some named imports are only used as types.


1-2: All these imports are only used as types.


2-3: All these imports are only used as types.


51-51: Avoid using the index of an array as key property in an element.


60-60: Avoid using the index of an array as key property in an element.


85-85: Avoid using the index of an array as key property in an element.

packages/components/calendar/src/calendar-picker.tsx (3)

2-3: All these imports are only used as types.


51-51: Avoid using the index of an array as key property in an element.


55-55: Avoid using the index of an array as key property in an element.

Additional comments not posted (2)
packages/components/calendar/src/calendar-month.tsx (1)

44-44: The change to use the spread syntax for the inert attribute is a good approach to conditionally apply attributes based on state.

packages/components/calendar/src/calendar-picker.tsx (1)

70-70: The change to use the spread syntax for the inert attribute is a good approach to conditionally apply attributes based on state.

@wingkwong wingkwong self-assigned this May 27, 2024
@KumJungMin KumJungMin changed the title fix(calendar): apply inert attribute according to isHeaderExpanded fix(datePicker): apply inert attribute according to isHeaderExpanded May 27, 2024
@jrgarciadev
Copy link
Member

@KumJungMin please add the changeset

@KumJungMin KumJungMin changed the title fix(datePicker): apply inert attribute according to isHeaderExpanded fix(calendar): apply inert attribute according to isHeaderExpanded May 28, 2024
@KumJungMin
Copy link
Contributor Author

KumJungMin commented May 29, 2024

@KumJungMin please add the changeset

thank you comment :)
i added changeset file (cd3c622)

Copy link
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.

Actionable comments posted: 2

Outside diff range and nitpick comments (2)
packages/components/calendar/src/calendar-month.tsx (1)

Line range hint 52-52: Avoid using array indices as keys for React elements to prevent issues with rendering performance and component state during re-renders.

Consider using a more stable identifier as a key, such as a unique property of the items being rendered.

Also applies to: 61-61, 86-86

packages/components/calendar/src/calendar-picker.tsx (1)

Line range hint 51-51: Avoid using array indices as keys for React elements to prevent issues with rendering performance and component state during re-renders.

Consider using a more stable identifier as a key, such as a unique property of the items being rendered.

Also applies to: 55-55

Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 01aa9cd and cd3c622.
Files selected for processing (3)
  • .changeset/two-snakes-behave.md (1 hunks)
  • packages/components/calendar/src/calendar-month.tsx (1 hunks)
  • packages/components/calendar/src/calendar-picker.tsx (1 hunks)
Files skipped from review due to trivial changes (1)
  • .changeset/two-snakes-behave.md
Additional Context Used
Biome (9)
packages/components/calendar/src/calendar-month.tsx (6)

1-1: Some named imports are only used as types.


1-2: All these imports are only used as types.


2-3: All these imports are only used as types.


52-52: Avoid using the index of an array as key property in an element.


61-61: Avoid using the index of an array as key property in an element.


86-86: Avoid using the index of an array as key property in an element.

packages/components/calendar/src/calendar-picker.tsx (3)

2-3: All these imports are only used as types.


51-51: Avoid using the index of an array as key property in an element.


55-55: Avoid using the index of an array as key property in an element.

@@ -42,7 +42,7 @@ export function CalendarMonth(props: CalendarMonthProps) {
// makes the browser ignore the element and its children when tabbing
// TODO: invert inert when switching to React 19 (ref: https://github.com/facebook/react/issues/17157)
// @ts-ignore
inert={isHeaderExpanded ? "" : undefined}
{...{inert: isHeaderExpanded ? "" : undefined}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using null instead of an empty string for the inert attribute to ensure compatibility across all browsers.

- {...{inert: isHeaderExpanded ? "" : undefined}}
+ {...{inert: isHeaderExpanded ? null : undefined}}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
{...{inert: isHeaderExpanded ? "" : undefined}}
{...{inert: isHeaderExpanded ? null : undefined}}

@@ -68,7 +68,7 @@ export function CalendarPicker(props: CalendarPickerProps) {
// makes the browser ignore the element and its children when tabbing
// TODO: invert inert when switching to React 19 (ref: https://github.com/facebook/react/issues/17157)
// @ts-ignore
inert={isHeaderExpanded ? undefined : ""}
{...{inert: isHeaderExpanded ? "" : undefined}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using null instead of an empty string for the inert attribute to ensure compatibility across all browsers.

- {...{inert: isHeaderExpanded ? "" : undefined}}
+ {...{inert: isHeaderExpanded ? null : undefined}}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
{...{inert: isHeaderExpanded ? "" : undefined}}
{...{inert: isHeaderExpanded ? null : undefined}}

@wingkwong
Copy link
Member

@KumJungMin can you double check if this issue is still reproducible in the current nextui documentation? I tired to use firebox to reproduce but i didn't see this error. Probably it could have been resolved in this PR.

@wingkwong wingkwong assigned KumJungMin and unassigned wingkwong Jun 25, 2024
@KumJungMin
Copy link
Contributor Author

@KumJungMin can you double check if this issue is still reproducible in the current nextui documentation? I tired to use firebox to reproduce but i didn't see this error. Probably it could have been resolved in this PR.


Oh! the issue was resolved :) thank you for check!

@KumJungMin KumJungMin closed this Jun 25, 2024
@KumJungMin KumJungMin deleted the fix/calendar-inert-error branch June 25, 2024 23:21
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.

None yet

3 participants