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: Leaving editable tab in error state #37981

Merged
merged 2 commits into from
Dec 6, 2024

Conversation

hetunandu
Copy link
Member

@hetunandu hetunandu commented Dec 5, 2024

Description

fixes the editable tab handling of error states. Earlier the tab would stay in error state (with tooltip active) when you leave (focus out or press esc) the input with an invalid value.

Now it would revert the context back to the old name and let go of the error state.

Automation

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

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12179074325
Commit: 0ba7f5f
Cypress dashboard.
Tags: @tag.Sanity
Spec:


Thu, 05 Dec 2024 14:27:54 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced validation handling for the EditableName component, improving user experience during name editing.
    • Tooltip behavior updated to show an empty string instead of validation messages during certain user interactions.
  • Bug Fixes

    • Improved logic for saving names, ensuring no unnecessary saves occur when the name hasn't changed.
  • Documentation

    • Clarified the validation error handling process in the component's interactions.

Copy link
Contributor

coderabbitai bot commented Dec 5, 2024

Walkthrough

The changes in this pull request focus on the EditableName component, specifically enhancing validation error handling during user interactions. The test file has been updated to expect an empty tooltip string instead of a validation error message in certain scenarios. The main component file has seen modifications to the attemptSave function, which now checks for name changes and manages validation errors more effectively. Additionally, useEffect hooks have been refined to ensure the editable name syncs properly with the props.

Changes

File Path Change Summary
app/client/src/IDE/Components/EditableName/EditableName.test.tsx Updated tooltip expectations for validation error handling in tests related to user interactions.
app/client/src/IDE/Components/EditableName/EditableName.tsx Enhanced attemptSave logic for name validation and saving; adjusted useEffect hooks for syncing.

Possibly related PRs

Suggested labels

High, IDE Product, IDE Pod

Suggested reviewers

  • ankitakinger
  • albinAppsmith

🎉 In the land of code, where names do dwell,
EditableName shines, casting its spell.
With tooltips now empty, errors take flight,
Saving names smoothly, all feels just right.
So here's to the changes, both clever and bright! 🌟


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 954e920 and 0ba7f5f.

📒 Files selected for processing (1)
  • app/client/src/IDE/Components/EditableName/EditableName.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/src/IDE/Components/EditableName/EditableName.tsx

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.

@github-actions github-actions bot added the Bug Something isn't working label Dec 5, 2024
@hetunandu
Copy link
Member Author

/build-deploy-preview

@hetunandu hetunandu added the ok-to-test Required label for CI label Dec 5, 2024
Copy link

github-actions bot commented Dec 5, 2024

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

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 (2)
app/client/src/IDE/Components/EditableName/EditableName.tsx (2)

75-86: Consider error state cleanup timing

The current implementation clears validation errors after setting the name. Consider clearing the error state before setting the new name to prevent potential flash of error state during state updates.

    } else {
      // Exit edit mode and revert name
+     setValidationError(null);
      setEditableName(name);
-     setValidationError(null);
      exitEditing();
    }

Line range hint 143-156: Improve focus management implementation

The current setTimeout-based focus management is fragile and could lead to race conditions. Consider using a more robust approach such as:

  1. MutationObserver to detect when focus retention completes
  2. RAF (requestAnimationFrame) for more reliable timing
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 80f2000 and 954e920.

📒 Files selected for processing (2)
  • app/client/src/IDE/Components/EditableName/EditableName.test.tsx (2 hunks)
  • app/client/src/IDE/Components/EditableName/EditableName.tsx (1 hunks)

@@ -151,7 +151,7 @@ describe("EditableName", () => {

await userEvent.click(document.body);

expect(getByRole("tooltip").textContent).toEqual(validationError);
expect(getByRole("tooltip").textContent).toEqual("");
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add tests for missing scenarios

While the current changes correctly verify the tooltip behavior, consider adding tests for:

  1. The case where the name hasn't changed (should call exitWithoutSaving)
  2. The transition timing of error states to ensure proper cleanup

Example test structure:

test("exits without saving when name hasn't changed", () => {
  const { exitEditing, getByRole, onNameSave } = setup({
    isEditing: true,
  });
  const inputElement = getByRole("textbox");

  // Set same name as original
  fireEvent.change(inputElement, {
    target: { value: name },
  });

  fireEvent.keyUp(inputElement, KEY_CONFIG.ENTER);

  expect(exitEditing).toHaveBeenCalled();
  expect(onNameSave).not.toHaveBeenCalled();
});

Also applies to: 190-190

ankitakinger
ankitakinger previously approved these changes Dec 5, 2024
Copy link

github-actions bot commented Dec 5, 2024

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

@hetunandu
Copy link
Member Author

/build-deploy-preview

Copy link

github-actions bot commented Dec 5, 2024

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

Copy link

github-actions bot commented Dec 5, 2024

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

@@ -29,6 +30,10 @@ interface EditableTextProps {
inputTestId?: string;
}

export const Text = styled(ADSText)`
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd move this to styles.

@hetunandu hetunandu merged commit a450226 into release Dec 6, 2024
44 checks passed
@hetunandu hetunandu deleted the fix/editable-tab-error-revert branch December 6, 2024 07:53
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Dec 9, 2024
This was referenced Dec 27, 2024
@coderabbitai coderabbitai bot mentioned this pull request Jan 6, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working ok-to-test Required label for CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants