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

chore: remove headless radio and use react-aria component instead #34312

Merged
merged 3 commits into from
Jun 19, 2024

Conversation

KelvinOm
Copy link
Collaborator

@KelvinOm KelvinOm commented Jun 18, 2024

Description

  • Remove headless radio and use react-aria component instead
  • Create ErrorMessage component

Fixes #27677

Automation

/ok-to-test tags="@tag.Anvil"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9567388261
Commit: 62d1153caa8bf03d827f88593c9dfaf3121091ee
Cypress dashboard.
Tags: @tag.Anvil

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Added ErrorMessage component for displaying error messages with specific styling.
    • Introduced isDisabled prop for Label and ToggleGroup components.
    • Updated RadioGroup to accept an items array for easier configuration.
  • Bug Fixes

    • Improved conditional rendering in Label component to prevent issues when text and contextualHelp are both falsy.
  • Refactor

    • Removed Radio component export from design system.
    • Restructured import statements and prop declarations for Checkbox and RadioGroup.
  • Style

    • Updated styles for RadioGroup and ToggleGroup components for better state handling (disabled, hovered, selected).
  • Documentation

    • Updated Storybook stories for RadioGroup to reflect changes in component usage.
  • Tests

    • Adjusted RadioGroup.test.tsx to test new items array prop.

@KelvinOm KelvinOm requested a review from jsartisan June 18, 2024 14:53
@github-actions github-actions bot added Anvil Pod Issue related to Anvil project Bug Something isn't working Medium Issues that frustrate users due to poor UX QA Needs QA attention QA Pod Issues under the QA Pod WDS team labels Jun 18, 2024
Copy link
Contributor

coderabbitai bot commented Jun 18, 2024

Walkthrough

The updates encompass various enhancements across several components within the design system module. Key changes include re-exporting components, introducing new props, adjusting styles, and removing outdated elements. Notably, this includes updates to Checkbox, Label, RadioGroup, and the addition of the ErrorMessage component, leading to better integration, functionality, and user experience within the system.

Changes

File Path Change Summary
app/client/packages/design-system/headless/src/index.ts Removed export for Radio
.../Checkbox/src/Checkbox.tsx Reorganized imports, adjusted CheckboxProps imports
.../Checkbox/src/index.ts Changed export location for CheckboxProps
.../Checkbox/src/types.ts Introduced CheckboxProps interface with labelPosition property
.../ErrorMessage/src/ErrorMessage.tsx Added new ErrorMessage component
.../ErrorMessage/src/index.ts Added export statement for ErrorMessage component
.../ErrorMessage/src/styles.module.css Introduced styling for ErrorMessage
.../ErrorMessage/src/types.ts Introduced ErrorMessageProps interface
.../Label/src/Label.tsx Updated to handle isDisabled prop and return null if both text and contextualHelp are falsy
.../Label/src/styles.module.css Added styles for disabled state
.../Label/src/types.ts Added isDisabled property to LabelProps
.../RadioGroup/src/RadioGroup.tsx Updated imports, adjusted RadioGroupProps to include new properties, refactored _RadioGroup component
.../RadioGroup/src/index.ts Changed export location for RadioGroupProps
.../RadioGroup/src/styles.module.css Adjusted styles for various states
.../RadioGroup/src/types.ts Introduced RadioGroupItemProps and RadioGroupProps interfaces
.../ToggleGroup/src/ToggleGroup.tsx Updated imports, added isDisabled prop, modified rendering logic
.../ToggleGroup/src/styles.module.css Removed disabled and error state styling
.../ToggleGroup/src/types.ts Added isDisabled property to RadioGroupItemProps
.../RadioGroup/stories/RadioGroup.stories.tsx Updated to use items array prop for RadioGroup instead of individual Radio components
.../RadioGroup/tests/RadioGroup.test.tsx Adjusted tests to reflect updates to RadioGroup component
.../ToggleGroup/chromatic/Group.chromatic.stories.tsx Updated RadioGroup to use items array prop
.../index.ts Removed Radio export, added ErrorMessage and hooks export
.../ComplexForm.tsx Replaced Radio components with items array in RadioGroup
.../storybook/src/components/DataAttrWrapper.tsx Added optional target prop

Sequence Diagram(s)

The changes are too varied and simple to warrant a unified sequence diagram.

Assessment against linked issues

Objective (Issue) Addressed Explanation
Checkbox getting focus on click instead of keyboard (#27677) The summary does not mention specific changes addressing the focus behavior for checkboxes.

Poem

In the garden of code, where widgets bloom,
Changes brighten up every room.
With labels that disable and errors that sing,
A Checkbox, once troubled, now takes wing 🌸.
Through the system, harmony flows anew,
Like a rabbit's hop, these updates grew! 🐇🌾


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 do a full 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.

@github-actions github-actions bot added skip-changelog Adding this label to a PR prevents it from being listed in the changelog and removed Bug Something isn't working labels Jun 18, 2024
@github-actions github-actions bot added the Bug Something isn't working label Jun 18, 2024
@KelvinOm KelvinOm added ok-to-test Required label for CI and removed Bug Something isn't working labels Jun 18, 2024
@github-actions github-actions bot added Bug Something isn't working and removed Bug Something isn't working labels Jun 18, 2024
@KelvinOm
Copy link
Collaborator Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/9567395642.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 34312.
recreate: .

@github-actions github-actions bot added Bug Something isn't working and removed Bug Something isn't working labels Jun 18, 2024
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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f718bfb and 62d1153caa8bf03d827f88593c9dfaf3121091ee.

Files selected for processing (20)
  • app/client/packages/design-system/headless/src/index.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/ErrorMessage/src/ErrorMessage.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/ErrorMessage/src/index.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/ErrorMessage/src/styles.module.css (1 hunks)
  • app/client/packages/design-system/widgets/src/components/ErrorMessage/src/types.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Label/src/Label.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Label/src/styles.module.css (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Label/src/types.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/RadioGroup/src/RadioGroup.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/RadioGroup/src/styles.module.css (6 hunks)
  • app/client/packages/design-system/widgets/src/components/RadioGroup/stories/RadioGroup.stories.tsx (4 hunks)
  • app/client/packages/design-system/widgets/src/components/RadioGroup/tests/RadioGroup.test.tsx (5 hunks)
  • app/client/packages/design-system/widgets/src/components/ToggleGroup/chromatic/Group.chromatic.stories.tsx (2 hunks)
  • app/client/packages/design-system/widgets/src/components/ToggleGroup/src/ToggleGroup.tsx (3 hunks)
  • app/client/packages/design-system/widgets/src/components/ToggleGroup/src/styles.module.css (2 hunks)
  • app/client/packages/design-system/widgets/src/components/ToggleGroup/src/types.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/index.ts (2 hunks)
  • app/client/packages/design-system/widgets/src/testing/ComplexForm.tsx (2 hunks)
  • app/client/src/widgets/wds/WDSRadioGroupWidget/widget/index.tsx (3 hunks)
  • app/client/src/widgets/wds/WDSRadioGroupWidget/widget/types.ts (1 hunks)
Files not reviewed due to errors (5)
  • app/client/packages/design-system/widgets/src/components/Label/src/Label.tsx (no review received)
  • app/client/packages/design-system/widgets/src/components/RadioGroup/stories/RadioGroup.stories.tsx (no review received)
  • app/client/packages/design-system/widgets/src/components/RadioGroup/src/RadioGroup.tsx (no review received)
  • app/client/packages/design-system/widgets/src/components/RadioGroup/tests/RadioGroup.test.tsx (no review received)
  • app/client/packages/design-system/widgets/src/components/RadioGroup/src/styles.module.css (no review received)
Files skipped from review due to trivial changes (6)
  • app/client/packages/design-system/widgets/src/components/ErrorMessage/src/index.ts
  • app/client/packages/design-system/widgets/src/components/ErrorMessage/src/styles.module.css
  • app/client/packages/design-system/widgets/src/components/ErrorMessage/src/types.ts
  • app/client/packages/design-system/widgets/src/components/Label/src/styles.module.css
  • app/client/packages/design-system/widgets/src/components/ToggleGroup/src/styles.module.css
  • app/client/packages/design-system/widgets/src/components/ToggleGroup/src/types.ts
Additional context used
Biome
app/client/packages/design-system/widgets/src/components/ErrorMessage/src/ErrorMessage.tsx

[error] 9-9: Avoid redundant Boolean call (lint/complexity/noExtraBooleanCast)

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call

app/client/packages/design-system/widgets/src/components/Label/src/Label.tsx

[error] 12-12: Avoid redundant Boolean call (lint/complexity/noExtraBooleanCast)

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call


[error] 12-12: Avoid redundant Boolean call (lint/complexity/noExtraBooleanCast)

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call

Additional comments not posted (12)
app/client/packages/design-system/widgets/src/components/Label/src/types.ts (1)

7-7: Addition of isDisabled property to LabelProps is a good enhancement for conditional rendering based on the disabled state.

app/client/packages/design-system/headless/src/index.ts (1)

Line range hint 1-10: The removal of the Radio component export is consistent with the PR's objectives to replace it with react-aria components. Ensure all dependent modules have been updated accordingly.

Verification successful

The removal of the Radio component export from index.ts is consistent with the PR's objectives to replace it with react-aria components. The search confirmed that no other files are importing the removed Radio component.

  • No imports found for the Radio component in the codebase.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that no other files are importing the removed Radio component.

# Test: Search for imports of the Radio component. Expect: No occurrences.
rg --type python --files-with-matches 'from "./components/Radio"'

Length of output: 98



Script:

#!/bin/bash
# Description: Verify that no other files are importing the removed Radio component.

# Test: Search for imports of the Radio component. Expect: No occurrences.
rg --type js,ts --files-with-matches 'from "./components/Radio"' || echo "No imports found for Radio component"

Length of output: 179



Script:

#!/bin/bash
# Description: Verify that no other files are importing the removed Radio component.

# Test: Search for imports of the Radio component. Expect: No occurrences.
rg --type-add 'ts:*.ts' --type-add 'js:*.js' --files-with-matches 'from "./components/Radio"' || echo "No imports found for Radio component"

Length of output: 178

app/client/src/widgets/wds/WDSRadioGroupWidget/widget/types.ts (1)

5-5: Update of options property to use RadioGroupProps["items"] aligns with the refactoring of the RadioGroup component to enhance modularity. Ensure this change is well integrated in the widget implementation.

app/client/packages/design-system/widgets/src/index.ts (2)

25-25: Correctly added export for ErrorMessage component.


29-29: Correctly added export for hooks.

app/client/packages/design-system/widgets/src/components/ToggleGroup/chromatic/Group.chromatic.stories.tsx (1)

30-30: Correct usage of items prop in RadioGroup and ToggleGroup components within the story configuration.

app/client/packages/design-system/widgets/src/components/ToggleGroup/src/ToggleGroup.tsx (3)

3-8: Correctly added necessary imports for ErrorMessage, Label, Flex, and useGroupOrientation.


21-21: Proper handling and destructuring of new props such as isDisabled, isRequired, items, and label.


37-37: Updated rendering logic correctly integrates new props and conditionally renders components based on these props.

Also applies to: 41-52, 56-56

app/client/src/widgets/wds/WDSRadioGroupWidget/widget/index.tsx (2)

9-9: The updated import statement correctly reflects the removal of the Radio component, aligning with the PR objectives.


Line range hint 125-138: The getWidgetView method has been updated to pass the items prop to the RadioGroup component, reflecting the changes in its API. Ensure that the labelTooltip is appropriately used as contextualHelp and that the validation logic correctly sets the isInvalid state.

app/client/packages/design-system/widgets/src/testing/ComplexForm.tsx (1)

107-127: The RadioGroup component's usage here correctly implements the new items prop structure. Each item is properly defined with value and label, ensuring clear and consistent options for the user.

Copy link

Deploy-Preview-URL: https://ce-34312.dp.appsmith.com

@KelvinOm KelvinOm force-pushed the fix/wds-radiobutton branch from 62d1153 to a71853d Compare June 18, 2024 16:09
@github-actions github-actions bot added Bug Something isn't working and removed Bug Something isn't working labels Jun 18, 2024
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: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 62d1153caa8bf03d827f88593c9dfaf3121091ee and a71853d.

Files selected for processing (22)
  • app/client/packages/design-system/headless/src/index.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/ErrorMessage/src/ErrorMessage.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/ErrorMessage/src/index.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/ErrorMessage/src/styles.module.css (1 hunks)
  • app/client/packages/design-system/widgets/src/components/ErrorMessage/src/types.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Label/src/Label.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Label/src/styles.module.css (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Label/src/types.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/RadioGroup/chromatic/RadioGroup.chromatic.stories.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/RadioGroup/src/RadioGroup.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/RadioGroup/src/styles.module.css (6 hunks)
  • app/client/packages/design-system/widgets/src/components/RadioGroup/stories/RadioGroup.stories.tsx (4 hunks)
  • app/client/packages/design-system/widgets/src/components/RadioGroup/tests/RadioGroup.test.tsx (5 hunks)
  • app/client/packages/design-system/widgets/src/components/ToggleGroup/chromatic/Group.chromatic.stories.tsx (2 hunks)
  • app/client/packages/design-system/widgets/src/components/ToggleGroup/src/ToggleGroup.tsx (3 hunks)
  • app/client/packages/design-system/widgets/src/components/ToggleGroup/src/styles.module.css (2 hunks)
  • app/client/packages/design-system/widgets/src/components/ToggleGroup/src/types.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/index.ts (2 hunks)
  • app/client/packages/design-system/widgets/src/testing/ComplexForm.tsx (2 hunks)
  • app/client/packages/storybook/src/components/DataAttrWrapper.tsx (2 hunks)
  • app/client/src/widgets/wds/WDSRadioGroupWidget/widget/index.tsx (3 hunks)
  • app/client/src/widgets/wds/WDSRadioGroupWidget/widget/types.ts (1 hunks)
Files skipped from review as they are similar to previous changes (18)
  • app/client/packages/design-system/headless/src/index.ts
  • app/client/packages/design-system/widgets/src/components/ErrorMessage/src/index.ts
  • app/client/packages/design-system/widgets/src/components/ErrorMessage/src/styles.module.css
  • app/client/packages/design-system/widgets/src/components/ErrorMessage/src/types.ts
  • app/client/packages/design-system/widgets/src/components/Label/src/styles.module.css
  • app/client/packages/design-system/widgets/src/components/Label/src/types.ts
  • app/client/packages/design-system/widgets/src/components/RadioGroup/src/RadioGroup.tsx
  • app/client/packages/design-system/widgets/src/components/RadioGroup/src/styles.module.css
  • app/client/packages/design-system/widgets/src/components/RadioGroup/stories/RadioGroup.stories.tsx
  • app/client/packages/design-system/widgets/src/components/RadioGroup/tests/RadioGroup.test.tsx
  • app/client/packages/design-system/widgets/src/components/ToggleGroup/chromatic/Group.chromatic.stories.tsx
  • app/client/packages/design-system/widgets/src/components/ToggleGroup/src/ToggleGroup.tsx
  • app/client/packages/design-system/widgets/src/components/ToggleGroup/src/styles.module.css
  • app/client/packages/design-system/widgets/src/components/ToggleGroup/src/types.ts
  • app/client/packages/design-system/widgets/src/index.ts
  • app/client/packages/design-system/widgets/src/testing/ComplexForm.tsx
  • app/client/src/widgets/wds/WDSRadioGroupWidget/widget/index.tsx
  • app/client/src/widgets/wds/WDSRadioGroupWidget/widget/types.ts
Additional context used
Biome
app/client/packages/design-system/widgets/src/components/ErrorMessage/src/ErrorMessage.tsx

[error] 9-9: Avoid redundant Boolean call (lint/complexity/noExtraBooleanCast)

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call

app/client/packages/design-system/widgets/src/components/Label/src/Label.tsx

[error] 12-12: Avoid redundant Boolean call (lint/complexity/noExtraBooleanCast)

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call


[error] 12-12: Avoid redundant Boolean call (lint/complexity/noExtraBooleanCast)

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call

app/client/packages/storybook/src/components/DataAttrWrapper.tsx

[error] 23-23: Avoid redundant Boolean call (lint/complexity/noExtraBooleanCast)

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call


[error] 35-35: Avoid redundant Boolean call (lint/complexity/noExtraBooleanCast)

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call

Additional comments not posted (4)
app/client/packages/design-system/widgets/src/components/ErrorMessage/src/ErrorMessage.tsx (1)

11-20: The error message rendering logic and properties are appropriately set.

app/client/packages/design-system/widgets/src/components/Label/src/Label.tsx (1)

17-17: The handling of the isDisabled prop with the data-disabled attribute is correctly implemented.

app/client/packages/storybook/src/components/DataAttrWrapper.tsx (1)

6-6: The addition of the optional target prop enhances the flexibility of the DataAttrWrapper component.

app/client/packages/design-system/widgets/src/components/RadioGroup/chromatic/RadioGroup.chromatic.stories.tsx (1)

20-35: The story definitions for the RadioGroup component are well-structured and provide a comprehensive demonstration of the component's states.

export const ErrorMessage = (props: ErrorMessageProps) => {
const { text } = props;

if (!Boolean(text)) return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Simplify the conditional check to improve readability.

-  if (!Boolean(text)) return null;
+  if (!text) return null;
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. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!Boolean(text)) return null;
if (!text) return null;
Tools
Biome

[error] 9-9: Avoid redundant Boolean call (lint/complexity/noExtraBooleanCast)

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call

const { className, contextualHelp, isDisabled, isRequired, text, ...rest } =
props;

if (!Boolean(text) && !Boolean(contextualHelp)) return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Simplify the conditional checks to improve code readability.

-  if (!Boolean(text) && !Boolean(contextualHelp)) return null;
+  if (!text && !contextualHelp) return null;
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. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!Boolean(text) && !Boolean(contextualHelp)) return null;
if (!text && !contextualHelp) return null;
Tools
Biome

[error] 12-12: Avoid redundant Boolean call (lint/complexity/noExtraBooleanCast)

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call


[error] 12-12: Avoid redundant Boolean call (lint/complexity/noExtraBooleanCast)

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call

@@ -19,7 +20,11 @@ export const DataAttrWrapper = (props: DataAttrWrapperProps) => {
Boolean(ref.current.setAttribute) &&
typeof ref.current.setAttribute === "function"
) {
ref.current.setAttribute(attr, "");
if (Boolean(target)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Simplify the conditional checks to improve code readability.

-  if (Boolean(target)) {
+  if (target) {
   ref.current.querySelector(target).setAttribute(attr, "");
-  if (Boolean(domNode)) domNode.setAttribute(attr, "");
+  if (domNode) domNode.setAttribute(attr, "");

Also applies to: 35-35

Tools
Biome

[error] 23-23: Avoid redundant Boolean call (lint/complexity/noExtraBooleanCast)

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call

Copy link
Contributor

Choose a reason for hiding this comment

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

QQ: didn't we decide to remove toggle group ( I remember a thread on slack you asking about it )

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nope, Taras said that we need it.

@github-actions github-actions bot added the Bug Something isn't working label Jun 19, 2024
@KelvinOm KelvinOm requested a review from jsartisan June 19, 2024 07:44
@KelvinOm
Copy link
Collaborator Author

/build-deploy-preview skip-tests=true

@KelvinOm KelvinOm requested a review from ramsaptami June 19, 2024 07:45
Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/9578137232.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 34312.
recreate: .

@KelvinOm KelvinOm removed the request for review from ramsaptami June 19, 2024 07:45
@github-actions github-actions bot removed the Bug Something isn't working label Jun 19, 2024
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 (1)
app/client/packages/design-system/widgets/src/components/Checkbox/src/Checkbox.tsx (1)

Line range hint 28-28: Consider removing the redundant Boolean calls. They are unnecessary as the values are already being used in a boolean context, and this simplifies the code.

- {Boolean(isIndeterminate) ? <Icon name="minus" /> : <Icon name="check" />}
+ {isIndeterminate ? <Icon name="minus" /> : <Icon name="check" />}
- {Boolean(isRequired) && (
+ {isRequired && (
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a71853d and 242c98b.

Files selected for processing (7)
  • app/client/packages/design-system/widgets/src/components/Checkbox/src/Checkbox.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Checkbox/src/index.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/Checkbox/src/types.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/RadioGroup/src/RadioGroup.tsx (1 hunks)
  • app/client/packages/design-system/widgets/src/components/RadioGroup/src/index.ts (1 hunks)
  • app/client/packages/design-system/widgets/src/components/RadioGroup/src/styles.module.css (5 hunks)
  • app/client/packages/design-system/widgets/src/components/RadioGroup/src/types.ts (1 hunks)
Files skipped from review due to trivial changes (3)
  • app/client/packages/design-system/widgets/src/components/Checkbox/src/index.ts
  • app/client/packages/design-system/widgets/src/components/Checkbox/src/types.ts
  • app/client/packages/design-system/widgets/src/components/RadioGroup/src/index.ts
Files skipped from review as they are similar to previous changes (2)
  • app/client/packages/design-system/widgets/src/components/RadioGroup/src/RadioGroup.tsx
  • app/client/packages/design-system/widgets/src/components/RadioGroup/src/styles.module.css
Additional context used
Biome
app/client/packages/design-system/widgets/src/components/Checkbox/src/Checkbox.tsx

[error] 28-28: Avoid redundant Boolean call (lint/complexity/noExtraBooleanCast)

It is not necessary to use Boolean call when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant Boolean call

Additional comments not posted (3)
app/client/packages/design-system/widgets/src/components/RadioGroup/src/types.ts (2)

4-10: LGTM! The RadioGroupItemProps interface is well-defined and appropriately scoped for individual radio items.


12-34: Excellent documentation and structuring of RadioGroupProps. The use of keyof typeof ORIENTATION for the orientation property enhances type safety and clarity.

app/client/packages/design-system/widgets/src/components/Checkbox/src/Checkbox.tsx (1)

6-6: The update to the import statement for CheckboxProps reflects the new organization of type definitions, aligning with best practices.

Copy link

Deploy-Preview-URL: https://ce-34312.dp.appsmith.com

@KelvinOm KelvinOm merged commit 3637246 into release Jun 19, 2024
21 of 22 checks passed
@KelvinOm KelvinOm deleted the fix/wds-radiobutton branch June 19, 2024 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Anvil Pod Issue related to Anvil project Medium Issues that frustrate users due to poor UX ok-to-test Required label for CI QA Pod Issues under the QA Pod QA Needs QA attention skip-changelog Adding this label to a PR prevents it from being listed in the changelog skip-docs WDS team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Checkbox when being used in canvas is getting focus even on click
2 participants