Skip to content

Commit 4f37310

Browse files
authored
feat: fix option label lose (#167)
* feat: fix option label lose * feat: add test case
1 parent 165f8ad commit 4f37310

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Mentions.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ const Mentions = React.forwardRef<MentionsRef, MentionsProps>((props, ref) => {
209209
key: React.Key;
210210
}) => ({
211211
...optionProps,
212+
label: optionProps.children,
212213
key: (key || optionProps.value) as string,
213214
}),
214215
);

tests/Mentions.spec.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,18 @@ describe('Mentions', () => {
175175
});
176176
expect(onChange).toHaveBeenCalledWith('bamboo');
177177
});
178+
179+
it('do not lose label', () => {
180+
const { container } = renderOptionsMentions();
181+
simulateInput(container, '@');
182+
fireEvent.mouseEnter(
183+
container.querySelector('li.rc-mentions-dropdown-menu-item:last-child'),
184+
);
185+
expect(
186+
container.querySelector('.rc-mentions-dropdown-menu-item-active')
187+
.textContent,
188+
).toBe('Cat');
189+
});
178190
});
179191

180192
describe('filterOption', () => {

0 commit comments

Comments
 (0)