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');
|
console.warn('Input is disabled or value is not defined');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit({ ...value, mode });
|
onSubmit({ ...value, mode });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ export const useCreateShortcutsMentionsSuggestions = (
|
||||||
popoverContent: ShortcutPopoverContent,
|
popoverContent: ShortcutPopoverContent,
|
||||||
popoverClassName: '',
|
popoverClassName: '',
|
||||||
onChangeTransform: (v) => {
|
onChangeTransform: (v) => {
|
||||||
const foundShortcut = shortcuts.find((shortcut) => shortcut.name === v.label);
|
const foundShortcut = shortcuts.find((shortcut) => shortcut.id === v.value);
|
||||||
if (foundShortcut) {
|
if (foundShortcut) {
|
||||||
return foundShortcut.instructions;
|
return foundShortcut.instructions;
|
||||||
}
|
}
|
||||||
|
@ -91,9 +91,9 @@ export const useCreateShortcutForMention = () => {
|
||||||
shortcut: Shortcut,
|
shortcut: Shortcut,
|
||||||
_editor?: Editor
|
_editor?: Editor
|
||||||
): MentionTriggerItem<string> => {
|
): MentionTriggerItem<string> => {
|
||||||
console.log('shortcut', shortcut);
|
|
||||||
return {
|
return {
|
||||||
value: shortcut.id,
|
value: shortcut.id,
|
||||||
|
labelMatches: [shortcut.name, shortcut.instructions],
|
||||||
label: (
|
label: (
|
||||||
<div className="flex flex-col space-y-1.5 py-1.5">
|
<div className="flex flex-col space-y-1.5 py-1.5">
|
||||||
<Text>{`${SHORTCUT_MENTION_TRIGGER}${shortcut.name}`}</Text>
|
<Text>{`${SHORTCUT_MENTION_TRIGGER}${shortcut.name}`}</Text>
|
||||||
|
|
|
@ -427,7 +427,7 @@ export const DynamicItems: Story = {
|
||||||
placeholder="Type ! to see dynamic mentions..."
|
placeholder="Type ! to see dynamic mentions..."
|
||||||
mentions={[dynamicSuggestions]}
|
mentions={[dynamicSuggestions]}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
console.log('Input changed:', value);
|
console.info('Input changed:', value);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ const PopoverWrapper = <T extends string>({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popover
|
<Popover
|
||||||
trigger="hover"
|
trigger="click"
|
||||||
align="start"
|
align="start"
|
||||||
side="bottom"
|
side="bottom"
|
||||||
sideOffset={8}
|
sideOffset={8}
|
||||||
|
|
|
@ -26,6 +26,12 @@ const itemMatchesQuery = (item: MentionTriggerItem, query: string): boolean => {
|
||||||
return results.length > 0;
|
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
|
// No match if label is not a string and no labelMatches provided
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue