Use EditableInput component in Toolbar
#2238
Merged
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.
Fixes #2237
(I can put in a PR with a 3-line CSS change if we want to fix just that issue and not all this other stuff)
Background:
We have a nice
EditableInputUI component which was created by @andrewn for the collection details page in #1164. This component displays a text with a pencil icon and converts it to an input when clicked. We use this same behavior when displaying the project name in the editor toolbar but we aren't using this component for it. We should use it!Changes:
EditableInputcomponent:aria-labelvia props (so we can still uset('Toolbar.EditSketchARIA')).disabledto render as plain text with no pencil icon and no hover effects (issue Project name looks clickable when viewing others' projects #2237)Esckey. This will discard any text typed into the input and revert to the initial value, without submitting or saving anything.aria-hiddenproperty on the label and the input when they are hidden via CSSdisplay: noneToolbarcomponent:EditableInputcomponent.EditableInput..toolbar__project-name, but leave behind a few overrides which apply to theEditableInputwhen used inside the.toolbarto keep the style the same as the current (thinner border, uses'secondary-text-color'instead of'inactive-text-color').isEditingstate management:isEditingis now a local component state of theEditableInputand does not need to be in Redux.showEditProjectNameandhideEditProjectNameand removeisEditingNamefrom state.Toolbar.unit.test.jsxfile can no longer see if these actions have been dispatched, so instead I'm looking at thedisabledandfocusedstates of the<input>element to determine whether or not it is editing.I have verified that this pull request:
npm run lint)npm run test)developbranch.Fixes #123