fix(editor): Use segments/graphemes when creating the compact sidebar entries (#9776)

This commit is contained in:
Danny Martini
2024-06-17 18:50:29 +02:00
committed by GitHub
parent 551fb6d7a2
commit be7249f568
3 changed files with 55 additions and 10 deletions

View File

@@ -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);
}
};
</script>
<style module lang="scss">