diff --git a/client/__tests__/e2e/e2eAnnotations.test.js b/client/__tests__/e2e/e2eAnnotations.test.js
index 30677321..7bd9ade1 100644
--- a/client/__tests__/e2e/e2eAnnotations.test.js
+++ b/client/__tests__/e2e/e2eAnnotations.test.js
@@ -183,8 +183,11 @@ describe.each([
});
async function assertCategoryExists(categoryName) {
- const result = await utils.waitByID(`${categoryName}:category-expand`);
- expect(await result.evaluate(node => node.innerText)).toBe(categoryName);
+ const handle = await utils.waitByID(`${categoryName}:category-expand`);
+ const result = await handle.evaluate(node => node.innerText);
+ // slice beginning and end of category name result to account for truncation of long names
+ expect(result.slice(0, 10)).toBe(categoryName.slice(0, 10));
+ expect(result.slice(-10)).toBe(categoryName.slice(-10));
}
async function assertCategoryDoesNotExist(categoryName) {
diff --git a/client/src/components/categorical/category.js b/client/src/components/categorical/category.js
index 9552086e..2e6b17ed 100644
--- a/client/src/components/categorical/category.js
+++ b/client/src/components/categorical/category.js
@@ -9,6 +9,7 @@ import AnnoDialogEditCategoryName from "./annoDialogEditCategoryName";
import AnnoDialogAddLabel from "./annoDialogAddLabel";
import * as globals from "../../globals";
+import maybeTruncateString from "../../util/maybeTruncateString";
@connect(state => ({
colorAccessor: state.colors.colorAccessor,
@@ -204,7 +205,7 @@ class Category extends React.Component {
{isUserAnno ? (
) : null}
- {metadataField}
+ {maybeTruncateString(metadataField, globals.categoryDisplayStringMaxLength)}
{isExpanded ? (
{
+
+ let truncatedString = null;
+ if (
+ str.length > maxLength
+ ) {
+ truncatedString = `${str.slice(
+ 0,
+ maxLength / 2
+ )}…${str.slice(
+ -maxLength / 2
+ )}`;
+ }
+
+ return truncatedString || str;
+}
+
+export default maybeTruncateString;
\ No newline at end of file