diff --git a/client/src/components/categorical/category.js b/client/src/components/categorical/category.js index f79dc526..7d53cff7 100644 --- a/client/src/components/categorical/category.js +++ b/client/src/components/categorical/category.js @@ -237,45 +237,6 @@ class Category extends React.Component { {""} - {/* Dialog uses portal, can be anywhere/factored out */} - - - - New, unique category name: - - this.setState({ newCategoryText: e.target.value }) - } - leftIcon="tag" - /> - - - - - - - Cancel - - - - Edit category name - - - - { - this.setState({ isExpanded: !isExpanded }); + const editingCategory = + annotations.isEditingCategoryName && + annotations.categoryBeingEdited === metadataField; + if (!editingCategory) { + this.setState({ isExpanded: !isExpanded }); + } }} > {isUserAnno ? ( ) : null} - {metadataField} + + {annotations.isEditingCategoryName && + annotations.categoryBeingEdited === metadataField ? ( + { + e.preventDefault(); + this.handleEditCategory(); + }} + > + { + this.editableCategoryInput = input; + }} + small + autoFocus + onChange={e => { + this.setState({ + newCategoryText: e.target.value + }); + }} + defaultValue={metadataField} + rightElement={ + + } + /> + + ) : ( + metadataField + )} + {isExpanded ? ( { this.setState({ editedLabelText: e.target.value }); }} diff --git a/client/src/reducers/annotations.js b/client/src/reducers/annotations.js index f1224114..09409b59 100644 --- a/client/src/reducers/annotations.js +++ b/client/src/reducers/annotations.js @@ -5,7 +5,7 @@ const Annotations = ( state = { isEditingCategoryName: false, isEditingLabelName: false, - categoryEditable: false, + categoryBeingEdited: false, labelEditable: { category: null, label: null } }, action @@ -34,19 +34,19 @@ const Annotations = ( return { ...state, isEditingCategoryName: true, - categoryEditable: action.data + categoryBeingEdited: action.data }; case "annotation: disable category edit mode": return { ...state, isEditingCategoryName: false, - categoryEditable: null + categoryBeingEdited: null }; case "annotation: category edited": return { ...state, isEditingCategoryName: true, - categoryEditable: null + categoryBeingEdited: null }; /* LABEL */
New, unique category name: