Skip to content

Conversation

@nandobutzke
Copy link
Contributor

This PR fixes an issue in the InlineEdit component where the current input value was incorrectly preserved after triggering the onCancel callback.

Previously, when onCancel was called, the value that had been modified in the input field was stored and reused, instead of reverting to the original unedited value.

The component now correctly resets the input to its initial value when canceling an edit.

Related issue: #4274

Screen.Recording.2025-05-10.at.12.27.07.AM.mov

@codesandbox
Copy link

codesandbox bot commented May 10, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@vercel
Copy link

vercel bot commented May 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rsuite-nextjs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 10, 2025 3:35pm
rsuite-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 10, 2025 3:35pm

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses the issue where the InlineEdit component preserved the edited input value on cancel instead of reverting to the original. It updates the focus handler to only trigger when appropriate and adds new test cases to ensure onFocus is only called once when the component is already in editing mode.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/InlineEdit/useEditState.ts Modified the focus handler to check for an active edit state before firing onFocus.
src/InlineEdit/test/InlineEditSpec.tsx Added tests to verify focus behavior, ensuring onFocus is only called on initial focus.
Comments suppressed due to low confidence (1)

src/InlineEdit/test/InlineEditSpec.tsx:173

  • Consider adding a test case that explicitly verifies the cancel action resets the input value to its original state, ensuring the bug is fully addressed.
it('Should have a custom size', () => {

@simonguo simonguo merged commit c1d98b5 into rsuite:main May 12, 2025
13 checks passed
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.

2 participants