mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-18 19:50:38 +09:00
fix(ui): avoid issue detail ref update loops
This commit is contained in:
parent
185195201a
commit
f5a87ab14e
2 changed files with 13 additions and 17 deletions
|
|
@ -379,16 +379,6 @@ export const MarkdownEditor = forwardRef<MarkdownEditorRef, MarkdownEditorProps>
|
||||||
return mentions.filter((m) => m.name.toLowerCase().includes(q)).slice(0, 8);
|
return mentions.filter((m) => m.name.toLowerCase().includes(q)).slice(0, 8);
|
||||||
}, [mentionState, mentions, slashCommands]);
|
}, [mentionState, mentions, slashCommands]);
|
||||||
|
|
||||||
const setEditorRef = useCallback((instance: MDXEditorMethods | null) => {
|
|
||||||
ref.current = instance;
|
|
||||||
if (instance) {
|
|
||||||
const v = valueRef.current;
|
|
||||||
echoIgnoreMarkdownRef.current = v;
|
|
||||||
instance.setMarkdown(v);
|
|
||||||
latestValueRef.current = v;
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useImperativeHandle(forwardedRef, () => ({
|
useImperativeHandle(forwardedRef, () => ({
|
||||||
focus: () => {
|
focus: () => {
|
||||||
ref.current?.focus(undefined, { defaultSelection: "rootEnd" });
|
ref.current?.focus(undefined, { defaultSelection: "rootEnd" });
|
||||||
|
|
@ -808,7 +798,7 @@ export const MarkdownEditor = forwardRef<MarkdownEditorRef, MarkdownEditorProps>
|
||||||
onPasteCapture={handlePasteCapture}
|
onPasteCapture={handlePasteCapture}
|
||||||
>
|
>
|
||||||
<MDXEditor
|
<MDXEditor
|
||||||
ref={setEditorRef}
|
ref={ref}
|
||||||
markdown={value}
|
markdown={value}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
onChange={(next) => {
|
onChange={(next) => {
|
||||||
|
|
|
||||||
|
|
@ -38,20 +38,24 @@ const buttonVariants = cva(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
function Button({
|
const Button = React.forwardRef<
|
||||||
|
HTMLButtonElement,
|
||||||
|
React.ComponentProps<"button"> &
|
||||||
|
VariantProps<typeof buttonVariants> & {
|
||||||
|
asChild?: boolean
|
||||||
|
}
|
||||||
|
>(function Button({
|
||||||
className,
|
className,
|
||||||
variant = "default",
|
variant = "default",
|
||||||
size = "default",
|
size = "default",
|
||||||
asChild = false,
|
asChild = false,
|
||||||
...props
|
...props
|
||||||
}: React.ComponentProps<"button"> &
|
}, ref) {
|
||||||
VariantProps<typeof buttonVariants> & {
|
|
||||||
asChild?: boolean
|
|
||||||
}) {
|
|
||||||
const Comp = asChild ? Slot.Root : "button"
|
const Comp = asChild ? Slot.Root : "button"
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Comp
|
<Comp
|
||||||
|
ref={ref}
|
||||||
data-slot="button"
|
data-slot="button"
|
||||||
data-variant={variant}
|
data-variant={variant}
|
||||||
data-size={size}
|
data-size={size}
|
||||||
|
|
@ -59,6 +63,8 @@ function Button({
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
})
|
||||||
|
|
||||||
|
Button.displayName = "Button"
|
||||||
|
|
||||||
export { Button, buttonVariants }
|
export { Button, buttonVariants }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue