From 54fd74357e381225488a4cb18493230aa7f11a0b Mon Sep 17 00:00:00 2001 From: lam Date: Thu, 21 Aug 2025 14:29:48 +0800 Subject: [PATCH] fix: #297 disabled option can be selected by pressing Enter key --- docs/examples/basic.tsx | 5 +++++ src/Mentions.tsx | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/examples/basic.tsx b/docs/examples/basic.tsx index b104de1..8e2f2db 100644 --- a/docs/examples/basic.tsx +++ b/docs/examples/basic.tsx @@ -31,6 +31,11 @@ export default () => ( value: 'bamboo', label: 'Bamboo', }, + { + value: 'dark', + label: 'Dark', + disabled: true, + }, { value: 'cat', label: 'Cat', diff --git a/src/Mentions.tsx b/src/Mentions.tsx index 84e978f..f5d5e99 100644 --- a/src/Mentions.tsx +++ b/src/Mentions.tsx @@ -297,7 +297,10 @@ const InternalMentions = forwardRef( }; const selectOption = (option: OptionProps) => { - const { value: mentionValue = '' } = option; + const { value: mentionValue = '', disabled } = option; + if (disabled) { + return; + } const { text, selectionLocation } = replaceWithMeasure(mergedValue, { measureLocation: mergedMeasureLocation, targetText: mentionValue,