Skip to content

fix(Label): reset edit state when canceling with escape - #12649

Open
fallmo wants to merge 1 commit into
patternfly:mainfrom
fallmo:fix-label-editable
Open

fix(Label): reset edit state when canceling with escape#12649
fallmo wants to merge 1 commit into
patternfly:mainfrom
fallmo:fix-label-editable

Conversation

@fallmo

@fallmo fallmo commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

What: Closes #12648

Pressing Escape during an inline label edit reverts the displayed text, but reopening the editor brings back the discarded draft.

The edit input is controlled by currValue, and the Escape handler was resetting the DOM node directly:

editableInputRef.current.value = children as string;

That has no effect on a controlled input, so currValue kept the draft. The fix resets the state instead:

setCurrValue(children);

This runs unconditionally, which also covers the case where the input is cleared before pressing Escape. Previously currValue stayed '' while the label displayed the original text. onEditCancel keeps its existing guard, so the callback behavior is unchanged.

Added two tests: reopening the editor after Escape shows the original text, and onEditCancel receives the previous text. No snapshot changes.

Additional issues: None

Summary by CodeRabbit

  • Bug Fixes
    • Fixed editable labels so pressing Escape reliably discards draft text and restores the original label value.
    • Ensured reopening the editor displays the restored value.
    • Preserved the edit-cancel callback behavior and previous-text argument.

Signed-off-by: Mohamed Fall <ps.hackmaster@gmail.com>
@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 662b082d-7fa2-41ea-b835-43c1f87152bd

📥 Commits

Reviewing files that changed from the base of the PR and between 533d86d and 8fe3290.

📒 Files selected for processing (2)
  • packages/react-core/src/components/Label/Label.tsx
  • packages/react-core/src/components/Label/__tests__/Label.test.tsx

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


Walkthrough

The editable label now resets its controlled value when Escape cancels editing. Tests verify that discarded drafts do not reappear and that onEditCancel receives the previous text.

Changes

Editable label Escape cancellation

Layer / File(s) Summary
Reset controlled value on Escape
packages/react-core/src/components/Label/Label.tsx, packages/react-core/src/components/Label/__tests__/Label.test.tsx
The cancel path uses setCurrValue(children). Tests verify draft removal after reopening and the onEditCancel argument.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 8fe32

Escape cancellation now restores the original label text and the changed behavior is covered by tests.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: resetting edit state when the user cancels an inline Label edit with Escape.
Linked Issues check ✅ Passed The change meets #12648. The Escape branch now calls setCurrValue(children), which resets the controlled input state to the original label text. The added test types a draft, cancels with Escape, re…
Out of Scope Changes check ✅ Passed The changes stay within #12648. The source change fixes Escape cancellation, and both added tests verify draft discard and existing cancellation callback behavior. No unrelated production or test chan…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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 - Label: canceling an inline edit with Escape keeps the discarded draft text

1 participant