diff --git a/client/src/components/categorical/category.js b/client/src/components/categorical/category.js index f47fe945..d824f1dc 100644 --- a/client/src/components/categorical/category.js +++ b/client/src/components/categorical/category.js @@ -2,7 +2,13 @@ import React from "react"; import _ from "lodash"; import { connect } from "react-redux"; import { FaChevronRight, FaChevronDown } from "react-icons/fa"; -import { AnchorButton, Button, Tooltip, Icon } from "@blueprintjs/core"; +import { + AnchorButton, + Button, + Tooltip, + Icon, + Position +} from "@blueprintjs/core"; import CategoryFlipperLayout from "./categoryFlipperLayout"; import AnnoMenu from "./annoMenuCategory"; import AnnoDialogEditCategoryName from "./annoDialogEditCategoryName"; @@ -164,6 +170,11 @@ class Category extends React.Component { false ); + const truncatedString = maybeTruncateString( + metadataField, + globals.categoryDisplayStringMaxLength + ); + return ( - { - const editingCategory = - annotations.isEditingCategoryName && - annotations.categoryBeingEdited === metadataField; - if (!editingCategory) { - onExpansionChange(metadataField); - } + - {isUserAnno ? ( - - ) : null} - {maybeTruncateString( - metadataField, - globals.categoryDisplayStringMaxLength - )} - {isExpanded ? ( - - ) : ( - - )} - + { + const editingCategory = + annotations.isEditingCategoryName && + annotations.categoryBeingEdited === metadataField; + if (!editingCategory) { + onExpansionChange(metadataField); + } + }} + > + {isUserAnno ? ( + + ) : null} + {truncatedString || metadataField} + {isExpanded ? ( + + ) : ( + + )} + + {} {} diff --git a/client/src/components/categorical/value.js b/client/src/components/categorical/value.js index 540dd475..6b8596fa 100644 --- a/client/src/components/categorical/value.js +++ b/client/src/components/categorical/value.js @@ -393,6 +393,12 @@ class CategoryValue extends React.Component { content={displayString} disabled={truncatedString === null} hoverOpenDelay={globals.tooltipHoverOpenDelayQuick} + position={Position.LEFT} + usePortal + modifiers={{ + preventOverflow: { enabled: false }, + hide: { enabled: false } + }} > { - let truncatedString = null; - if ( - str.length > maxLength - ) { - truncatedString = `${str.slice( - 0, - maxLength / 2 - )}…${str.slice( + if (str.length > maxLength) { + truncatedString = `${str.slice(0, maxLength / 2)}…${str.slice( -maxLength / 2 )}`; - } + } - return truncatedString || str; -} + return truncatedString; +}; -export default maybeTruncateString; \ No newline at end of file +export default maybeTruncateString;