feat: Sort document tags alphabetically and prevent hover/focus on empty folder menu items.
This commit is contained in:
@@ -472,7 +472,11 @@ const DocumentSummarySection: React.FC<DocumentSummarySectionProps> = ({
|
|||||||
id: tag.id,
|
id: tag.id,
|
||||||
label: tag.label,
|
label: tag.label,
|
||||||
color: tag.color ?? tagLookupById.get(tag.id)?.color ?? null,
|
color: tag.color ?? tagLookupById.get(tag.id)?.color ?? null,
|
||||||
}));
|
})).sort((a, b) => {
|
||||||
|
const labelA = (a.label || '').toLowerCase();
|
||||||
|
const labelB = (b.label || '').toLowerCase();
|
||||||
|
return labelA.localeCompare(labelB);
|
||||||
|
});
|
||||||
}, [document?.tags, tagLookupById]);
|
}, [document?.tags, tagLookupById]);
|
||||||
|
|
||||||
const resolvedCorrespondents = useMemo(() => {
|
const resolvedCorrespondents = useMemo(() => {
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ const SelectionFolderMenu: React.FC<SelectionFolderMenuProps> = ({
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={item.id}
|
key={item.id}
|
||||||
className="menu__item selection-assignment__item"
|
className={`menu__item selection-assignment__item${!hasChildren ? ' selection-assignment__item--empty' : ''}`}
|
||||||
role="menuitem"
|
role="menuitem"
|
||||||
>
|
>
|
||||||
{/* Clickable area to navigate down */}
|
{/* Clickable area to navigate down */}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { getTagColorStyle } from '../../utils/colors';
|
import { getTagColorStyle } from '../../utils/colors';
|
||||||
import { writeTagTransferData } from '../tagTransfer';
|
import { writeTagTransferData } from '../tagTransfer';
|
||||||
import type { DocumentTag } from '../../types/documents';
|
import type { DocumentTag } from '../../types/documents';
|
||||||
@@ -23,13 +23,21 @@ const DocumentTags: React.FC<DocumentTagsProps> = ({
|
|||||||
onTagDragStart,
|
onTagDragStart,
|
||||||
onTagDragEnd,
|
onTagDragEnd,
|
||||||
}) => {
|
}) => {
|
||||||
|
const sortedTags = useMemo(() => {
|
||||||
|
return [...tags].sort((a, b) => {
|
||||||
|
const labelA = (a.label || '').toLowerCase();
|
||||||
|
const labelB = (b.label || '').toLowerCase();
|
||||||
|
return labelA.localeCompare(labelB);
|
||||||
|
});
|
||||||
|
}, [tags]);
|
||||||
|
|
||||||
if (tags.length === 0) {
|
if (tags.length === 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{tags.map((tag, index) => {
|
{sortedTags.map((tag, index) => {
|
||||||
const colorSource = tag?.color || tagLookupById?.get(tag.id)?.color;
|
const colorSource = tag?.color || tagLookupById?.get(tag.id)?.color;
|
||||||
const style = getTagColorStyle(colorSource);
|
const style = getTagColorStyle(colorSource);
|
||||||
const tagId = tag?.id ?? null;
|
const tagId = tag?.id ?? null;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import type { Identifier } from '../../types/identifiers';
|
|||||||
import type { DocumentTag } from '../../types/documents';
|
import type { DocumentTag } from '../../types/documents';
|
||||||
|
|
||||||
interface EntryTagsProps {
|
interface EntryTagsProps {
|
||||||
tags: Identifier[];
|
tags: DocumentTag[];
|
||||||
tagLookupById?: Map<Identifier, DocumentTag> | null;
|
tagLookupById?: Map<Identifier, DocumentTag> | null;
|
||||||
onTagClick?: (tagId: Identifier) => void;
|
onTagClick?: (tagId: Identifier) => void;
|
||||||
docId: Identifier;
|
docId: Identifier;
|
||||||
|
|||||||
@@ -847,3 +847,9 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.25rem;
|
gap: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.menu .selection-assignment__item--empty:hover,
|
||||||
|
.menu .selection-assignment__item--empty:focus-visible {
|
||||||
|
background: transparent;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user