Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix(ui): add tabs panel focus treatment (#41231)

yyh9ce92d8605d8
diff --git a/packages/dify-ui/src/tabs/index.stories.tsx b/packages/dify-ui/src/tabs/index.stories.tsx
index 0b207f5766b..14895dcded7 100644
--- a/packages/dify-ui/src/tabs/index.stories.tsx
+++ b/packages/dify-ui/src/tabs/index.stories.tsx
@@ -45,6 +45,11 @@ export const Basic: Story = {
await userEvent.click(activityTab)
await expect(activityTab).toHaveAttribute('aria-selected', 'true')
- await expect(canvas.getByRole('tabpanel', { name: 'Activity' })).toBeVisible()
+ const activityPanel = canvas.getByRole('tabpanel', { name: 'Activity' })
+ await expect(activityPanel).toBeVisible()
+
+ await userEvent.tab()
+
+ await expect(activityPanel).toHaveFocus()
},
}
diff --git a/packages/dify-ui/src/tabs/index.tsx b/packages/dify-ui/src/tabs/index.tsx
index db8df75fa87..97716f28d35 100644
--- a/packages/dify-ui/src/tabs/index.tsx
+++ b/packages/dify-ui/src/tabs/index.tsx
@@ -31,8 +31,21 @@ function TabsTab({ className, ...props }: TabsTabProps) {
)
}
-type TabsPanelProps = BaseTabsNS.Panel.Props
-const TabsPanel = BaseTabs.Panel
+type TabsPanelProps = Omit<BaseTabsNS.Panel.Props, 'className'> & {
+ className?: string
+}
+
+function TabsPanel({ className, ...props }: TabsPanelProps) {
+ return (
+ <BaseTabs.Panel
+ className={cn(
+ 'outline-hidden focus-visible:inset-ring-2 focus-visible:inset-ring-state-accent-solid',
+ className,
+ )}
+ {...props}
+ />
+ )
+}
const TabsIndicator = BaseTabs.Indicator
type TabsIndicatorProps = BaseTabsNS.Indicator.Props