fix: select placeholder title text when rename field opens#29
Merged
Conversation
Section/Subsection/Unit renaming (outline tree and the standalone Unit page) focused the rename field but never selected its text, so builders had to manually clear the "Section"/"Subsection"/"Unit" placeholder before typing. Add select-on-focus so the whole title is highlighted and ready to be typed over, matching the old Backbone Studio behavior (xblock_string_field_editor.js's `input.focus().select()`).
Replace the direct edits to CardHeader.tsx and HeaderTitle.jsx with a standalone focusin listener (generic/select-title-on-focus.js), wired up once from index.jsx. This keeps the two rename-field components byte-identical to openedx/frontend-app-authoring, so future upstream merges don't conflict on this change.
Replace the direct edits to CardHeader.tsx and HeaderTitle.jsx with a standalone focusin listener (generic/select-title-on-focus.js), wired up once from index.jsx. This keeps the two rename-field components byte-identical to openedx/frontend-app-authoring, so future upstream merges don't conflict on this change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Summary
"Section"/"Subsection"/"Unit" placeholder before renaming a new item
— this worked automatically on the old Backbone Studio outline but
was dropped when the outline moved to this MFE.
focusinlistener(
generic/select-title-on-focus.js, initialized once fromindex.jsx) rather than editing the rename fields inCardHeader.tsx/HeaderTitle.jsxdirectly, so thoseupstream-tracked components stay untouched and this change won't
conflict with future merges from openedx/frontend-app-authoring.
[data-testid$="-edit-field"](Section/Subsection/Unit cards inthe outline tree) or
[data-testid="unit-header-title"] input(standalone Unit page title) and selects the full text.
Test plan
generic/select-title-on-focus.test.js: verifies each fieldtype gets selected on focus, unrelated inputs are untouched, and
the listener isn't double-attached.
npm test— 44/44 tests pass.Section, Subsection, and Unit now highlights the title on open.