mirror of https://github.com/buster-so/buster.git
short cuts need to track by id
This commit is contained in:
parent
743d0d71c9
commit
e66e344f1c
|
@ -100,6 +100,7 @@ export const BusterChatInputBase: React.FC<BusterChatInputProps> = React.memo(
|
|||
console.warn('Input is disabled or value is not defined');
|
||||
return;
|
||||
}
|
||||
|
||||
onSubmit({ ...value, mode });
|
||||
};
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ export const useCreateShortcutsMentionsSuggestions = (
|
|||
popoverContent: ShortcutPopoverContent,
|
||||
popoverClassName: '',
|
||||
onChangeTransform: (v) => {
|
||||
const foundShortcut = shortcuts.find((shortcut) => shortcut.name === v.label);
|
||||
const foundShortcut = shortcuts.find((shortcut) => shortcut.id === v.value);
|
||||
if (foundShortcut) {
|
||||
return foundShortcut.instructions;
|
||||
}
|
||||
|
@ -91,9 +91,9 @@ export const useCreateShortcutForMention = () => {
|
|||
shortcut: Shortcut,
|
||||
_editor?: Editor
|
||||
): MentionTriggerItem<string> => {
|
||||
console.log('shortcut', shortcut);
|
||||
return {
|
||||
value: shortcut.id,
|
||||
labelMatches: [shortcut.name, shortcut.instructions],
|
||||
label: (
|
||||
<div className="flex flex-col space-y-1.5 py-1.5">
|
||||
<Text>{`${SHORTCUT_MENTION_TRIGGER}${shortcut.name}`}</Text>
|
||||
|
|
|
@ -427,7 +427,7 @@ export const DynamicItems: Story = {
|
|||
placeholder="Type ! to see dynamic mentions..."
|
||||
mentions={[dynamicSuggestions]}
|
||||
onChange={(value) => {
|
||||
console.log('Input changed:', value);
|
||||
console.info('Input changed:', value);
|
||||
}}
|
||||
/>
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ const PopoverWrapper = <T extends string>({
|
|||
|
||||
return (
|
||||
<Popover
|
||||
trigger="hover"
|
||||
trigger="click"
|
||||
align="start"
|
||||
side="bottom"
|
||||
sideOffset={8}
|
||||
|
|
|
@ -26,6 +26,12 @@ const itemMatchesQuery = (item: MentionTriggerItem, query: string): boolean => {
|
|||
return results.length > 0;
|
||||
}
|
||||
|
||||
if (typeof item.pillLabel === 'string') {
|
||||
const pillLabelFuse = new Fuse([item.pillLabel], fuseConfig);
|
||||
const results = pillLabelFuse.search(query);
|
||||
return results.length > 0;
|
||||
}
|
||||
|
||||
// No match if label is not a string and no labelMatches provided
|
||||
return false;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue