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(dify-ui): keep scrolled items off the edge in Select and menus (#43946)

yyh6d9a5f2a8ad1
diff --git a/packages/dify-ui/docs/styling.md b/packages/dify-ui/docs/styling.md
index ad3efa9daff..b2dd645274b 100644
--- a/packages/dify-ui/docs/styling.md
+++ b/packages/dify-ui/docs/styling.md
@@ -64,6 +64,15 @@ Use semantic Dify tokens and existing component variants before hard-coded value
primitive classes. Use an important modifier only for a tightly scoped compatibility override
after the owning variant, data attribute, and selector structure cannot express the state.
+## Scroll padding
+
+An item scrolled into view, by the keyboard or on open, keeps the same inset from the visible edge
+as it has at the ends of the list. Other rows may be clipped there; that shows more content follows.
+
+Padding scrolls away with the content, so a scroll container with vertical padding around its items
+sets matching scroll padding on the same element. Primitives own this pair. A call site adds the
+height of a header or group label that must stay visible with the target item.
+
## Focus indicator
`src/internal/focus.ts` owns the outer and inset focus-visible rings and the separated indicator
diff --git a/packages/dify-ui/src/internal/menu.ts b/packages/dify-ui/src/internal/menu.ts
index 25372ed07cf..94905f73201 100644
--- a/packages/dify-ui/src/internal/menu.ts
+++ b/packages/dify-ui/src/internal/menu.ts
@@ -9,5 +9,7 @@ export const menuItemDestructiveClassName =
export const menuPopupBaseClassName =
'max-h-(--available-height) overflow-y-auto overflow-x-hidden text-sm text-text-secondary outline-hidden focus:outline-hidden focus-visible:outline-hidden'
+// The popup scrolls through `menuPopupBaseClassName`, so its vertical padding scrolls away with the
+// items. The scroll padding repeats that padding; change both together.
export const menuPopupSurfaceClassName =
- 'rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur py-1 shadow-lg backdrop-blur-[5px]'
+ 'rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur py-1 scroll-py-1 shadow-lg backdrop-blur-[5px]'
diff --git a/packages/dify-ui/src/select/index.tsx b/packages/dify-ui/src/select/index.tsx
index b8ffd72bdb5..6938a4f652f 100644
--- a/packages/dify-ui/src/select/index.tsx
+++ b/packages/dify-ui/src/select/index.tsx
@@ -206,7 +206,10 @@ function SelectList({ className, ...props }: SelectListProps) {
return (
<BaseSelect.List
className={(state) =>
- cn('max-h-80 overflow-auto p-1 outline-hidden', resolveClassName(className, state))
+ cn(
+ 'max-h-80 scroll-py-1 overflow-auto p-1 outline-hidden',
+ resolveClassName(className, state),
+ )
}
{...props}
/>