Skip to content

Commit be6edc8

Browse files
fix: resolved PR comments part 2
1 parent ef6622f commit be6edc8

3 files changed

Lines changed: 23 additions & 13 deletions

File tree

kits/agentic/mockai/components/ui/collapsible.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ function Collapsible({
1111

1212
function CollapsibleTrigger({
1313
...props
14-
}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {
14+
}: React.ComponentProps<typeof CollapsiblePrimitive.Trigger>) {
1515
return (
16-
<CollapsiblePrimitive.CollapsibleTrigger
16+
<CollapsiblePrimitive.Trigger
1717
data-slot="collapsible-trigger"
1818
{...props}
1919
/>
@@ -22,9 +22,9 @@ function CollapsibleTrigger({
2222

2323
function CollapsibleContent({
2424
...props
25-
}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {
25+
}: React.ComponentProps<typeof CollapsiblePrimitive.Content>) {
2626
return (
27-
<CollapsiblePrimitive.CollapsibleContent
27+
<CollapsiblePrimitive.Content
2828
data-slot="collapsible-content"
2929
{...props}
3030
/>

kits/agentic/mockai/components/ui/form.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ type FormFieldContextValue<
2525
name: TName
2626
}
2727

28-
const FormFieldContext = React.createContext<FormFieldContextValue>(
29-
{} as FormFieldContextValue,
30-
)
28+
const FormFieldContext = React.createContext<FormFieldContextValue | null>(null)
3129

3230
const FormField = <
3331
TFieldValues extends FieldValues = FieldValues,
@@ -45,13 +43,17 @@ const FormField = <
4543
const useFormField = () => {
4644
const fieldContext = React.useContext(FormFieldContext)
4745
const itemContext = React.useContext(FormItemContext)
48-
const { getFieldState } = useFormContext()
49-
const formState = useFormState({ name: fieldContext.name })
50-
const fieldState = getFieldState(fieldContext.name, formState)
5146

5247
if (!fieldContext) {
5348
throw new Error('useFormField should be used within <FormField>')
5449
}
50+
if (!itemContext) {
51+
throw new Error('useFormField should be used within <FormItem>')
52+
}
53+
54+
const { getFieldState } = useFormContext()
55+
const formState = useFormState({ name: fieldContext.name })
56+
const fieldState = getFieldState(fieldContext.name, formState)
5557

5658
const { id } = itemContext
5759

@@ -69,9 +71,7 @@ type FormItemContextValue = {
6971
id: string
7072
}
7173

72-
const FormItemContext = React.createContext<FormItemContextValue>(
73-
{} as FormItemContextValue,
74-
)
74+
const FormItemContext = React.createContext<FormItemContextValue | null>(null)
7575

7676
function FormItem({ className, ...props }: React.ComponentProps<'div'>) {
7777
const id = React.useId()

kits/agentic/mockai/components/ui/sidebar.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ function SidebarProvider({
9696
// Adds a keyboard shortcut to toggle the sidebar.
9797
React.useEffect(() => {
9898
const handleKeyDown = (event: KeyboardEvent) => {
99+
const target = event.target as HTMLElement | null
100+
const isEditable =
101+
!!target?.closest('input, textarea, select, [contenteditable="true"]') ||
102+
target?.isContentEditable
103+
104+
if (isEditable) return;
99105
if (
100106
event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
101107
(event.metaKey || event.ctrlKey)
@@ -284,6 +290,7 @@ function SidebarRail({ className, ...props }: React.ComponentProps<'button'>) {
284290

285291
return (
286292
<button
293+
type="button"
287294
data-sidebar="rail"
288295
data-slot="sidebar-rail"
289296
aria-label="Toggle Sidebar"
@@ -423,6 +430,7 @@ function SidebarGroupAction({
423430

424431
return (
425432
<Comp
433+
{...(!asChild ? { type: 'button' as const } : {})}
426434
data-slot="sidebar-group-action"
427435
data-sidebar="group-action"
428436
className={cn(
@@ -513,6 +521,7 @@ function SidebarMenuButton({
513521

514522
const button = (
515523
<Comp
524+
{...(!asChild ? { type: 'button' as const } : {})}
516525
data-slot="sidebar-menu-button"
517526
data-sidebar="menu-button"
518527
data-size={size}
@@ -558,6 +567,7 @@ function SidebarMenuAction({
558567

559568
return (
560569
<Comp
570+
{...(!asChild ? { type: 'button' as const } : {})}
561571
data-slot="sidebar-menu-action"
562572
data-sidebar="menu-action"
563573
className={cn(

0 commit comments

Comments
 (0)