From be7249f568d922238c1a95c9d182a01b25ac0ddb Mon Sep 17 00:00:00 2001 From: Danny Martini Date: Mon, 17 Jun 2024 18:50:29 +0200 Subject: [PATCH] fix(editor): Use segments/graphemes when creating the compact sidebar entries (#9776) --- .../src/components/N8nMenuItem/MenuItem.vue | 11 +------ .../N8nMenuItem/__tests__/labelUtil.spec.ts | 29 +++++++++++++++++++ .../src/components/N8nMenuItem/labelUtil.ts | 25 ++++++++++++++++ 3 files changed, 55 insertions(+), 10 deletions(-) create mode 100644 packages/design-system/src/components/N8nMenuItem/__tests__/labelUtil.spec.ts create mode 100644 packages/design-system/src/components/N8nMenuItem/labelUtil.ts diff --git a/packages/design-system/src/components/N8nMenuItem/MenuItem.vue b/packages/design-system/src/components/N8nMenuItem/MenuItem.vue index 8922525f73..f29fad87f9 100644 --- a/packages/design-system/src/components/N8nMenuItem/MenuItem.vue +++ b/packages/design-system/src/components/N8nMenuItem/MenuItem.vue @@ -97,6 +97,7 @@ import N8nIcon from '../N8nIcon'; import ConditionalRouterLink from '../ConditionalRouterLink'; import type { IMenuItem } from '../../types'; import { doesMenuItemMatchCurrentRoute } from './routerUtil'; +import { getInitials } from './labelUtil'; interface MenuItemProps { item: IMenuItem; @@ -149,16 +150,6 @@ const isItemActive = (item: IMenuItem): boolean => { Array.isArray(item.children) && item.children.some((child) => isActive(child)); return isActive(item) || hasActiveChild; }; - -const getInitials = (label: string): string => { - const words = label.split(' '); - - if (words.length === 1) { - return words[0].substring(0, 2); - } else { - return words[0].charAt(0) + words[1].charAt(0); - } -};