Skip to content

Commit 0626649

Browse files
committed
fix: use memoized structure
1 parent 02b580a commit 0626649

File tree

1 file changed

+22
-19
lines changed
  • packages/compass-components/src/components/document-list

1 file changed

+22
-19
lines changed

packages/compass-components/src/components/document-list/element.tsx

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -460,27 +460,30 @@ export const HadronElement: React.FunctionComponent<{
460460
} = useHadronElement(element);
461461

462462
// Add context menu hook for the field
463-
const fieldContextMenuRef = useContextMenuItems([
464-
{
465-
label: 'Copy field & value',
466-
onAction: () => {
467-
const fieldStr = `${key.value}: ${objectToIdiomaticEJSON(
468-
value.originalValue
469-
)}`;
470-
void navigator.clipboard.writeText(fieldStr);
463+
const fieldContextMenuRef = useContextMenuItems(
464+
() => [
465+
{
466+
label: 'Copy field & value',
467+
onAction: () => {
468+
const fieldStr = `${key.value}: ${objectToIdiomaticEJSON(
469+
value.originalValue
470+
)}`;
471+
void navigator.clipboard.writeText(fieldStr);
472+
},
471473
},
472-
},
473-
...(type.value === 'String' && isValidUrl(value.value)
474-
? [
475-
{
476-
label: 'Open URL in browser',
477-
onAction: () => {
478-
window.open(value.value, '_blank', 'noopener');
474+
...(type.value === 'String' && isValidUrl(value.value)
475+
? [
476+
{
477+
label: 'Open URL in browser',
478+
onAction: () => {
479+
window.open(value.value, '_blank', 'noopener');
480+
},
479481
},
480-
},
481-
]
482-
: []),
483-
]);
482+
]
483+
: []),
484+
],
485+
[key.value, value.originalValue, value.value, type.value]
486+
);
484487

485488
const toggleExpanded = () => {
486489
if (expanded) {

0 commit comments

Comments
 (0)