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:retained input reference on x icon click #36268

Open
wants to merge 1 commit into
base: release
Choose a base branch
from

Conversation

saiprabhu-dandanayak
Copy link
Contributor

@saiprabhu-dandanayak saiprabhu-dandanayak commented Sep 12, 2024

Description

Fixes : #18536

I have raised this pr in-order to retain the cursor position inside the search field when clicking on the x icon .

Screenshots

Table

Screenshot from 2024-09-12 13-56-18

SingleSelectTree

Screenshot from 2024-09-12 13-57-21

MultiTreeSelect

image

MultiSelect

image

Summary by CodeRabbit

  • New Features

    • Enhanced search and filter clearing functionality across multiple components to automatically focus the input field after clearing, improving user experience.
  • Bug Fixes

    • Added focus actions to clear buttons in various components to ensure immediate interaction with the input field post-clear.
  • Documentation

    • Added console log statements for better tracking of query changes and dropdown opening events in the SelectComponent.

Copy link
Contributor

coderabbitai bot commented Sep 12, 2024

Walkthrough

The changes in this pull request enhance user interaction by adding focus functionality to input elements when clear buttons are clicked across various components. Specifically, the SearchComponent, MultiSelectTreeWidget, MultiSelectWidgetV2, SingleSelectTreeWidget, and SelectWidget have been updated to ensure that the input field regains focus after clearing its contents, improving usability. Additionally, the SelectComponent includes new console log statements for debugging purposes.

Changes

File Path Change Summary
app/client/packages/design-system/widgets-old/src/SearchComponent/index.tsx Added a private property inputRef to focus the input field after clearing the search.
app/client/src/widgets/MultiSelectTreeWidget/component/index.tsx Enhanced clearButton to focus the input field after clearing the filter.
app/client/src/widgets/MultiSelectWidgetV2/component/index.tsx Modified clearButton to focus the input field before clearing the filter.
app/client/src/widgets/SelectWidget/component/index.tsx Added console logs in onQueryChange and onOpening methods for debugging purposes.
app/client/src/widgets/SingleSelectTreeWidget/component/index.tsx Updated clearButton to focus the input field after resetting the filter state.

Possibly related PRs

Suggested labels

Bug, Anvil team, ok-to-test

Poem

In the land of code where inputs reside,
A clear button now brings focus with pride.
With a click, the search field awaits,
Ready for typing, it patiently states.
Debugging logs whisper, "We're here to assist,"
Enhancing the flow, none can resist! ✨


Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f930ea1 and ba04252.

Files selected for processing (5)
  • app/client/packages/design-system/widgets-old/src/SearchComponent/index.tsx (2 hunks)
  • app/client/src/widgets/MultiSelectTreeWidget/component/index.tsx (1 hunks)
  • app/client/src/widgets/MultiSelectWidgetV2/component/index.tsx (1 hunks)
  • app/client/src/widgets/SelectWidget/component/index.tsx (2 hunks)
  • app/client/src/widgets/SingleSelectTreeWidget/component/index.tsx (1 hunks)
Files skipped from review due to trivial changes (1)
  • app/client/src/widgets/SelectWidget/component/index.tsx
Additional comments not posted (6)
app/client/packages/design-system/widgets-old/src/SearchComponent/index.tsx (3)

89-89: Great work on adding the inputRef property! 👍

This is a crucial step towards achieving the PR objective of retaining the cursor position in the search field after clearing the search. By creating a reference to the input element, you can now programmatically focus the input field when needed.


116-118: Excellent job on updating the clearSearch method! 🌟

By checking if inputRef is set and calling the focus method on the input element, you have successfully implemented the desired behavior of retaining the cursor position in the search field after clearing the search. This enhancement greatly improves the user experience and aligns perfectly with the PR objective.


125-125: Nice work on passing the inputRef to the SearchInputWrapper component! 👌

This step is essential to ensure that the inputRef is correctly linked to the actual input element rendered by the component. By doing so, you enable the programmatic focusing of the input field when the clearSearch method is called.

app/client/src/widgets/MultiSelectTreeWidget/component/index.tsx (1)

168-177: Great work! The changes fulfill the PR objective.

The updated clearButton component now sets focus back to the input field after clearing the filter. This aligns perfectly with the goal of retaining the cursor position and allowing users to continue typing seamlessly.

The code changes are clean, concise, and effectively address the user experience enhancement. Well done!

app/client/src/widgets/SingleSelectTreeWidget/component/index.tsx (1)

175-184: Great work on improving the user experience! 👍

I like how you've updated the clear button's onClick handler to refocus the input field after clearing the filter. This change will make it easier for users to continue typing a new filter without having to manually click back into the input field.

The code looks good and aligns well with the overall goal of the PR to enhance the interaction flow when clearing input fields. Keep up the great work! 🌟

app/client/src/widgets/MultiSelectWidgetV2/component/index.tsx (1)

174-183: Great work on improving the user experience! 👍

This change ensures that the input field regains focus after the user clicks the clear button, allowing them to immediately continue typing without having to manually click back into the input. The conditional check for inputRef.current is also a good defensive programming practice to avoid potential errors.

These enhancements align perfectly with the PR objective of retaining the cursor position in the search field when the x icon is clicked. Keep up the excellent work in making the application more user-friendly! 🙌


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

@saiprabhu-dandanayak
Copy link
Contributor Author

@appsmithorg/query-js-pod , Please add reviewer for this pr if you have enough bandwidth.
Thanks in advance.

@NilanshBansal
Copy link
Contributor

Assigned @rahulbarwal @jacquesikot from Widgets team for review. cc: @carinanfonseca

@saiprabhu-dandanayak
Copy link
Contributor Author

Hi @jacquesikot , could you pls review this pr , pls let me know any changes needs to be done.
Thanks in advance.

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.

[Bug]-[4000]:On clicking the 'x' icon in search fields, retain the cursor position inside the search field
2 participants