I think the problem might be with context menu id, it should always be unique according to the documentation. Try adding a random string to the id.
const getHighlightText = (text, keyword, value) => {
const startIndex = text.indexOf(keyword);
const entryId = value.entryid;
const entryParent = value.entryparent;
const entryType = value.entrytype;
const randomString1 = `${entryId}-${btoa(Math.random().toString()).substring(0,16)}`
const randomString2 = `${entryParent}-${btoa(Math.random().toString()).substring(0,16)}`
return startIndex !== -1 ? (
<span>
{text.substring(0, startIndex)}
<span style={{ color: '#03a0ce' }}>
<ContextMenuTrigger id={randomString1} holdToDisplay={1000}>
{text.substring(startIndex, startIndex + keyword.length)}
</ContextMenuTrigger>
<ContextMenu id={randomString1} hideOnLeave={true}>
{(catalogType === 'M' || catalogType === 'L') ?
<MenuItem data={{event: 'CreateLibrary'}}
onClick={(event) => handleClickOnCatalogIcon(event, 'createLibrary')}
>
Create Library
</MenuItem> : null}
</ContextMenu>
</span>
{text.substring(startIndex + keyword.length)}
</span>
) : (
<span>
<ContextMenuTrigger id={randomString2} holdToDisplay={1000}>
{text}
</ContextMenuTrigger>
<ContextMenu id={randomString2} hideOnLeave={true}>
{(catalogType === 'M' || catalogType === 'L') ?
<MenuItem data={{event: 'CreateLibrary'}}
onClick={(event) => handleClickOnCatalogIcon(event, 'createLibrary')}
>
Create Library
</MenuItem> : null}
</ContextMenu>
</span>
);
};
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…