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: enable allow clear options for single select dropdown #39213

Merged
merged 1 commit into from
Feb 12, 2025

Conversation

sneha122
Copy link
Contributor

@sneha122 sneha122 commented Feb 12, 2025

Description

This PR enables allow clear option for single select dropdowns in the UQI.

Fixes #39087
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

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

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/13284739979
Commit: 36b6c94
Cypress dashboard.
Tags: @tag.Datasource
Spec:


Wed, 12 Feb 2025 12:41:11 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features
    • Enhanced the dropdown control to allow users to clear their selection even in single-select mode, offering greater flexibility in interaction.
  • Tests
    • Expanded test coverage with new tests ensuring that the clear selection feature works correctly in single-select scenarios.

Copy link
Contributor

coderabbitai bot commented Feb 12, 2025

Walkthrough

This pull request introduces a new test suite in the DropDownControl component to verify single select functionality. The tests now cover scenarios with a single value, including the ability to clear the selection. Additionally, the component’s logic for displaying the clear option has been updated to allow clearing when the component is explicitly set to allow it through a new property (isAllowClear), regardless of whether it is a multi-select component.

Changes

File Change Summary
app/client/src/.../DropDownControl.test.tsx Added a new test suite "DropdownControl Single select tests" with variables (initialValuesSingleSelect, mockActionSingleSelect, dropDownPropsSingleSelect) and a test case for verifying the clear functionality in single select mode.
app/client/src/.../DropDownControl.tsx Updated the allowClear logic in the renderDropdown function to consider isAllowClear along with multi-select status; extended the DropDownControlProps interface to include the new optional isAllowClear property.

Sequence Diagram(s)

sequenceDiagram
    participant T as Test Runner
    participant D as DropDownControl
    participant S as Store/State
    T->>D: Render dropdown in single select mode (isAllowClear enabled)
    D->>S: Load initial single select values
    T->>D: Simulate click on Clear button
    D->>D: Evaluate condition (isMultiSelect || isAllowClear) && !isEmpty(selectedValue)
    D-->>T: Clear selection confirmed
Loading

Possibly related PRs

Suggested labels

Bug, Widgets Product, Query & JS Pod, ok-to-test, Medium, Task, Integrations Product

Suggested reviewers

  • AmanAgarwal041

Poem

In our code garden, tests now unfurl,
A clear button magic in a single-select swirl.
Values vanish with a swift, neat click,
A tiny change that makes components tick.
Happy code, shining bright like a star! ✨
Let the dropdown dance—test and deploy afar!


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@github-actions github-actions bot added High This issue blocks a user from building or impacts a lot of users Integrations Pod General Issues related to the Integrations Pod that don't fit into other tags. Integrations Product Issues related to a specific integration Query & JS Pod Issues related to the query & JS Pod Query & Widgets Pod All issues related to Query, JS, Eval, and Widgets Salesforce integration Issues related to salesforce saas integration Task A simple Todo Zendesk integration Issues related to zendesk saas integration Bug Something isn't working labels Feb 12, 2025
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

🧹 Nitpick comments (3)
app/client/src/components/formControls/DropDownControl.test.tsx (2)

224-296: Consider adding more test cases for comprehensive coverage.

The test suite verifies the clear functionality but would benefit from additional test cases:

  1. Initial value rendering
  2. Selecting a new value
  3. Clear button disabled state when no value is selected

249-263: Add negative test case for isAllowClear.

Add a test case where isAllowClear is set to false to verify that the clear button is not rendered.

app/client/src/components/formControls/DropDownControl.tsx (1)

370-370: Add JSDoc documentation for isAllowClear prop.

Add documentation to explain the purpose and behavior of this prop.

+  /** Whether to show clear button for single select dropdown */
   isAllowClear?: boolean;
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e878088 and 36b6c94.

📒 Files selected for processing (2)
  • app/client/src/components/formControls/DropDownControl.test.tsx (1 hunks)
  • app/client/src/components/formControls/DropDownControl.tsx (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-build / client-build
🔇 Additional comments (1)
app/client/src/components/formControls/DropDownControl.tsx (1)

307-309: LGTM! Clean implementation of the clear functionality.

The condition (props.isMultiSelect || props.isAllowClear) && !isEmpty(selectedValue) correctly handles both multi-select and single-select cases.

@sneha122 sneha122 added the ok-to-test Required label for CI label Feb 12, 2025
@sneha122
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

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

Copy link

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

@sneha122 sneha122 merged commit be3809f into release Feb 12, 2025
47 checks passed
@sneha122 sneha122 deleted the feat/dropdown-control-enable-allow-clear-UQI branch February 12, 2025 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working High This issue blocks a user from building or impacts a lot of users Integrations Pod General Issues related to the Integrations Pod that don't fit into other tags. Integrations Product Issues related to a specific integration ok-to-test Required label for CI Query & JS Pod Issues related to the query & JS Pod Query & Widgets Pod All issues related to Query, JS, Eval, and Widgets Salesforce integration Issues related to salesforce saas integration Task A simple Todo Zendesk integration Issues related to zendesk saas integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task]: Enable clear functionality for drop down control in the uqi
2 participants