Skip to content

Commit

Permalink
fix(feedback): form closing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrBulanek committed Oct 29, 2024
1 parent a8db861 commit 2f4dfde
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
4 changes: 0 additions & 4 deletions src/modules/chat/message/ActionBar.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
transform: translateY(-50%);
}

:where(.root) {
opacity: 0;
}

:where(.btnWrapper) {
:global(.#{$prefix}--btn--ghost) {
border-color: $border-subtle-00;
Expand Down
12 changes: 3 additions & 9 deletions src/modules/chat/message/ActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { CopyButton, IconButton, InlineLoading } from '@carbon/react';
import { Reset } from '@carbon/react/icons';
import clsx from 'clsx';
import { AnimatePresence, motion } from 'framer-motion';
import { useEffect, useId } from 'react';
import { useId } from 'react';
import { useRetry } from '../hooks/useRetry';
import { useChat } from '../providers/ChatProvider';
import { useMessageFeedback } from '../providers/MessageFeedbackProvider';
Expand All @@ -39,17 +39,11 @@ export function ActionBar({ message, visible, isPast, className }: Props) {
const { pending, retry, isDeleting } = useRetry(message);
const { assistant } = useChat();

const { closeForm } = useMessageFeedback();

useEffect(() => {
if (!visible) {
closeForm();
}
}, [visible, closeForm]);
const { formOpen } = useMessageFeedback();

return (
<AnimatePresence>
{visible && (
{(visible || formOpen) && (
<motion.aside
{...fadeProps()}
key={`${id}:root`}
Expand Down
3 changes: 3 additions & 0 deletions src/modules/chat/message/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ export const Message = memo(function Message({
className={clsx(classes.root, { [classes.hovered]: showActions })}
{...focusWithinProps}
{...contentHover.hoverProps}
onBlur={() => {
setFocusWithin(false);
}}
>
<Container size="sm" className={classes.container}>
<div
Expand Down
4 changes: 4 additions & 0 deletions src/modules/chat/message/feedback/MessageFeedbackForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export function MessageFeedbackForm() {
controllerProps={{
control: form.control,
name: 'categories',
disabled: isSubmitting,
}}
>
{label}
Expand All @@ -91,6 +92,7 @@ export function MessageFeedbackForm() {
labelText="Comments (optional)"
placeholder="Add more details on what went wrong and how the answer could be improved"
rows={4}
autoFocus
{...form.register('comment', {
maxLength: {
value: COMMENT_MAX_LENGTH,
Expand Down Expand Up @@ -129,6 +131,7 @@ function Item({
const { field } = useController({
control: controllerProps.control,
name: controllerProps.name,
disabled: controllerProps.disabled,
});

const prevValue = useMemo(() => field.value || [], [field.value]);
Expand Down Expand Up @@ -157,6 +160,7 @@ function Item({

handleChange(value, !isSelected);
}}
disabled={controllerProps.disabled}
>
{children}
</Tag>
Expand Down

0 comments on commit 2f4dfde

Please sign in to comment.