Skip to content

chore: external merge request from Contributor#36473

Closed
rahulbarwal wants to merge 15 commits intoreleasefrom
external-contri/fix/bug-icon-disappears-when-data-type-as-number-and-position-is-right-in-phone-input-widget-35549
Closed

chore: external merge request from Contributor#36473
rahulbarwal wants to merge 15 commits intoreleasefrom
external-contri/fix/bug-icon-disappears-when-data-type-as-number-and-position-is-right-in-phone-input-widget-35549

Conversation

@rahulbarwal
Copy link
Contributor

@rahulbarwal rahulbarwal commented Sep 23, 2024

Description

Fixes #35992

Original PR: #35992
EE PR: https://github.com/appsmithorg/appsmith-ee/pull/5202

Automation

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

🔍 Cypress test results

Caution

If you modify the content in this section, you are likely to disrupt the CI result for your PR.

Communication

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

  • Yes
  • No

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11047143152
Commit: 96e9284
Cypress dashboard.
Tags: @tag.All
Spec:


Thu, 26 Sep 2024 10:37:18 UTC

Summary by CodeRabbit

  • New Features
    • Introduced the ability to display an icon on the right side of the input component based on user-defined properties.

saiprabhu-dandanayak and others added 2 commits August 30, 2024 10:20
…s-when-data-type-as-number-and-position-is-right-in-phone-input-widget-35549' into external-contri/fix/bug-icon-disappears-when-data-type-as-number-and-position-is-right-in-phone-input-widget-35549
@rahulbarwal rahulbarwal self-assigned this Sep 23, 2024
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Sep 23, 2024
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 23, 2024

Important

Review skipped

Draft detected.

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.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request introduces a new constant ICON_ALIGN_RIGHT and a variable rightElement in the BaseInputComponent class. The rightElement is conditionally rendered based on the iconAlign prop and the presence of the iconName prop. This allows the component to display an icon on the right side when specified, enhancing its functionality.

Changes

File Change Summary
app/client/src/widgets/BaseInputWidget/component/index.tsx Introduced ICON_ALIGN_RIGHT constant and rightElement variable for conditional rendering of the right icon.

Assessment against linked issues

Objective Addressed Explanation
Fix icon alignment when datatype is of image (#35992)

Suggested labels

Bug, IDE Product, ok-to-test

Suggested reviewers

  • ApekshaBhosale
  • ankitakinger
  • ashit-rath

Poem

In the realm of code, a new icon's grace,
On the right it will shine, taking its place.
With props aligned, it stands so bright,
A fix for the bug, now everything's right!
Let’s celebrate this change, a joyful delight! 🎉


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@rahulbarwal rahulbarwal marked this pull request as draft September 23, 2024 06:17
@rahulbarwal rahulbarwal added the ok-to-test Required label for CI label Sep 23, 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

Outside diff range and nitpick comments (1)
app/client/src/widgets/BaseInputWidget/component/index.tsx (1)

533-538: Good job, class! Let's review your work.

I'm pleased to see you've addressed the icon alignment issue. Your solution looks correct and aligns well with our lesson objectives. However, let's make a small improvement to enhance code readability.

Consider extracting the rightElement logic into a separate method, like this:

+  private getRightElement = () => {
+    return this.props.iconAlign === ICON_ALIGN_RIGHT && this.props.iconName
+      ? <Tag icon={this.props.iconName} />
+      : undefined;
+  }

   // In the render method:
-  const rightElement = (
-    this.props.iconAlign === ICON_ALIGN_RIGHT && this.props.iconName
-      ? <Tag icon={this.props.iconName} />
-      : undefined
-  );
+  const rightElement = this.getRightElement();

This change will make your code more organized and easier to maintain. Remember, clean code is happy code!

Also applies to: 574-574

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7685c85 and e762b63.

Files selected for processing (1)
  • app/client/src/widgets/BaseInputWidget/component/index.tsx (2 hunks)
Additional comments not posted (1)
app/client/src/widgets/BaseInputWidget/component/index.tsx (1)

Line range hint 1-1010: Class dismissed! Let's recap today's lesson.

Overall, you've done a commendable job addressing the icon alignment issue. Your solution is on the right track and shows good understanding of the component's structure. Here's a summary of our review:

  1. The implementation of rightElement effectively solves the icon alignment problem for numeric inputs.
  2. We've suggested a small refactoring to improve code organization.
  3. We've asked you to verify that the solution works consistently across all input types.

Remember, attention to detail and consistency are key to becoming an A+ developer. Keep up the good work, and don't forget to apply these principles to all parts of your code!

Comment on lines +533 to +538
const ICON_ALIGN_RIGHT = 'right';
const rightElement = (
this.props.iconAlign === ICON_ALIGN_RIGHT && this.props.iconName
? <Tag icon={this.props.iconName} />
: undefined
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Ensure rightElement Consistency Across All Input Components

It appears that rightElement is utilized in multiple input components, including MultiSelectWidgetV2, SingleSelectTreeWidget, MultiSelectTreeWidget, and InputWidget. Please verify that the icon alignment changes applied to the numeric input are consistently implemented across all these input types to maintain uniform behavior throughout the application.

Analysis chain

Pop quiz time! Let's think about our other input types.

You've done a great job fixing the icon alignment for numeric inputs. But remember, in our class, we have many types of inputs. Can you show me how this change affects other input types?

Let's do a little homework to make sure our fix works for all input types:

After running these tests, please review the results and ensure that the icon alignment is consistent across all input types. If not, consider applying a similar fix to other input type implementations.

Also applies to: 574-574


Great effort on running the initial checks! It looks like rg didn't recognize the typescript file type. Let's adjust our approach to ensure we cover all TypeScript files properly.

Please run the following scripts to verify the rightElement usage across all input types:

Once you've executed these scripts, please share the results so we can ensure that the icon alignment is consistently applied across all input types. This will help maintain the reliability and uniformity of our component.


Let's refine our approach to ensure we effectively check the rightElement usage across all input types.

Please run the following scripts to accurately target .ts and .tsx files without relying on the --type flag:

Once you've executed these scripts, please share the results so we can ensure that the icon alignment is consistently applied across all input types. This adjustment will help maintain the reliability and uniformity of our component.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the rightElement logic is applied consistently across all input types

# Test: Search for other input type implementations
echo "Searching for other input type implementations:"
rg --type typescript "private \w+InputComponent" app/client/src/widgets/BaseInputWidget/component/index.tsx

# Test: Check if rightElement is used in other input type implementations
echo "Checking if rightElement is used in other input type implementations:"
rg --type typescript "rightElement[=:]" app/client/src/widgets/BaseInputWidget/component/index.tsx

Length of output: 534


Script:

# Description: Check if the rightElement logic is applied consistently across all input types

# Test: Search for other input type implementations by targeting .ts and .tsx files
echo "Searching for other input type implementations:"
rg --type-add 'ts=**/*.{ts,tsx}' --type ts "private \w+InputComponent" app/client/src/widgets/BaseInputWidget/component/index.tsx

# Test: Check if rightElement is used in other input type implementations
echo "Checking if rightElement is used in other input type implementations:"
rg --type-add 'ts=**/*.{ts,tsx}' --type ts "rightElement[=:]" app/client/src/widgets/BaseInputWidget/component/index.tsx

Length of output: 628


Script:

#!/bin/bash
# Description: Check if the rightElement logic is applied consistently across all input types

# Test: Search for other input type implementations by targeting .ts and .tsx files
echo "Searching for other input type implementations:"
rg "private \w+InputComponent" $(fd --extension ts --extension tsx app/client/src/widgets/BaseInputWidget/component/index.tsx)

# Test: Check if rightElement is used in other input type implementations
echo "Checking if rightElement is used in other input type implementations:"
rg "rightElement[=:]" $(fd --extension ts --extension tsx app/client/src/widgets/BaseInputWidget/component/index.tsx)

Length of output: 1986

@rahulbarwal rahulbarwal added Widgets & Accelerators Pod Issues related to widgets & Accelerators Shadow PR labels Sep 23, 2024
…sition-is-right-in-phone-input-widget-35549' of https://github.com/saiprabhu-dandanayak/appsmith into external-contri/fix/bug-icon-disappears-when-data-type-as-number-and-position-is-right-in-phone-input-widget-35549
…sition-is-right-in-phone-input-widget-35549' of https://github.com/saiprabhu-dandanayak/appsmith into external-contri/fix/bug-icon-disappears-when-data-type-as-number-and-position-is-right-in-phone-input-widget-35549
@saiprabhu-dandanayak
Copy link
Contributor

Hi @rahulbarwal , took recent pull from release branch and ran BasicLint_spec.ts file getting error in 9th testcase from what is work around to resolve this issue.
Thanks in advance.

…o external-contri/fix/bug-icon-disappears-when-data-type-as-number-and-position-is-right-in-phone-input-widget-35549
…sition-is-right-in-phone-input-widget-35549' of https://github.com/saiprabhu-dandanayak/appsmith into external-contri/fix/bug-icon-disappears-when-data-type-as-number-and-position-is-right-in-phone-input-widget-35549
…o external-contri/fix/bug-icon-disappears-when-data-type-as-number-and-position-is-right-in-phone-input-widget-35549
…sition-is-right-in-phone-input-widget-35549' of https://github.com/saiprabhu-dandanayak/appsmith into external-contri/fix/bug-icon-disappears-when-data-type-as-number-and-position-is-right-in-phone-input-widget-35549
…o external-contri/fix/bug-icon-disappears-when-data-type-as-number-and-position-is-right-in-phone-input-widget-35549
…sition-is-right-in-phone-input-widget-35549' of https://github.com/saiprabhu-dandanayak/appsmith into external-contri/fix/bug-icon-disappears-when-data-type-as-number-and-position-is-right-in-phone-input-widget-35549
@rahulbarwal
Copy link
Contributor Author

Original PR merged, this is not required anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Required label for CI Shadow PR skip-changelog Adding this label to a PR prevents it from being listed in the changelog Widgets & Accelerators Pod Issues related to widgets & Accelerators

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants