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
EditableInput
UI 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:
EditableInput
component:aria-label
via props (so we can still uset('Toolbar.EditSketchARIA')
).disabled
to render as plain text with no pencil icon and no hover effects (issue Project name looks clickable when viewing others' projects #2237)Esc
key. This will discard any text typed into the input and revert to the initial value, without submitting or saving anything.aria-hidden
property on the label and the input when they are hidden via CSSdisplay: none
Toolbar
component:EditableInput
component.EditableInput
..toolbar__project-name
, but leave behind a few overrides which apply to theEditableInput
when used inside the.toolbar
to keep the style the same as the current (thinner border, uses'secondary-text-color'
instead of'inactive-text-color'
).isEditing
state management:isEditing
is now a local component state of theEditableInput
and does not need to be in Redux.showEditProjectName
andhideEditProjectName
and removeisEditingName
from state.Toolbar.unit.test.jsx
file can no longer see if these actions have been dispatched, so instead I'm looking at thedisabled
andfocused
states 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
)develop
branch.Fixes #123