Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
87e7c23d
authored
Dec 20, 2024
by
Archer
Committed by
GitHub
Dec 20, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
4.8.16 test (#3445)
* perf: model selector ux * perf: model selector ux
parent
e6d53e3d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
8 deletions
+21
-8
packages/web/components/common/MySelect/MultipleRowSelect.tsx
+20
-8
projects/app/src/components/Select/AIModelSelector.tsx
+1
-0
No files found.
packages/web/components/common/MySelect/MultipleRowSelect.tsx
View file @
87e7c23d
...
@@ -24,10 +24,12 @@ export const MultipleRowSelect = ({
...
@@ -24,10 +24,12 @@ export const MultipleRowSelect = ({
emptyTip
,
emptyTip
,
maxH
=
300
,
maxH
=
300
,
onSelect
,
onSelect
,
popDirection
=
'bottom'
,
ButtonProps
,
ButtonProps
,
changeOnEverySelect
=
false
changeOnEverySelect
=
false
,
}:
MultipleSelectProps
)
=>
{
rowMinWidth
=
'autp'
}:
MultipleSelectProps
&
{
rowMinWidth
?:
string
;
})
=>
{
const
{
t
}
=
useTranslation
();
const
{
t
}
=
useTranslation
();
const
ButtonRef
=
useRef
<
HTMLButtonElement
>
(
null
);
const
ButtonRef
=
useRef
<
HTMLButtonElement
>
(
null
);
...
@@ -58,6 +60,15 @@ export const MultipleRowSelect = ({
...
@@ -58,6 +60,15 @@ export const MultipleRowSelect = ({
const children = list[selectedIndex]?.children || [];
const children = list[selectedIndex]?.children || [];
const hasChildren = list.some((item) => item.children && item.children?.length > 0);
const hasChildren = list.some((item) => item.children && item.children?.length > 0);
// Store current scroll position before update
const currentScrollTop = MenuRef.current[index]?.scrollTop;
// Use useEffect to restore scroll position after render
useEffect(() => {
if (currentScrollTop !== undefined && MenuRef.current[index]) {
MenuRef.current[index]!.scrollTop = currentScrollTop;
}
}, [cloneValue, currentScrollTop]);
return (
return (
<>
<>
<Box
<Box
...
@@ -68,7 +79,7 @@ export const MultipleRowSelect = ({
...
@@ -68,7 +79,7 @@ export const MultipleRowSelect = ({
flex={'1 0 auto'}
flex={'1 0 auto'}
px={2}
px={2}
borderLeft={index !== 0 ? 'base' : 'none'}
borderLeft={index !== 0 ? 'base' : 'none'}
minW={index !== 0 ? minWidth :
'auto'
}
minW={index !== 0 ? minWidth :
rowMinWidth
}
maxH={`
$
{
maxH
}
px
`}
maxH={`
$
{
maxH
}
px
`}
overflowY={'auto'}
overflowY={'auto'}
whiteSpace={'nowrap'}
whiteSpace={'nowrap'}
...
@@ -81,10 +92,11 @@ export const MultipleRowSelect = ({
...
@@ -81,10 +92,11 @@ export const MultipleRowSelect = ({
SelectedItemRef.current[index] = ref;
SelectedItemRef.current[index] = ref;
}
}
}}
}}
py={2}
py={1.5}
_notLast={{ mb: 1 }}
cursor={'pointer'}
cursor={'pointer'}
px={
2
}
px={
1.5
}
borderRadius={'
md
'}
borderRadius={'
sm
'}
_hover={{
_hover={{
bg: 'primary.50'
bg: 'primary.50'
}}
}}
...
@@ -194,7 +206,6 @@ export const MultipleRowSelect = ({
...
@@ -194,7 +206,6 @@ export const MultipleRowSelect = ({
: `
$
{
width
}
!
important
`;
: `
$
{
width
}
!
important
`;
})()}
})()}
w={'auto'}
w={'auto'}
px={'6px'}
py={'6px'}
py={'6px'}
border={'1px solid #fff'}
border={'1px solid #fff'}
boxShadow={
boxShadow={
...
@@ -204,6 +215,7 @@ export const MultipleRowSelect = ({
...
@@ -204,6 +215,7 @@ export const MultipleRowSelect = ({
maxH={'40vh'}
maxH={'40vh'}
overflowY={'auto'}
overflowY={'auto'}
display={'flex'}
display={'flex'}
userSelect={'none'}
>
>
<RenderList list={list} index={0} />
<RenderList list={list} index={0} />
</MenuList>
</MenuList>
...
...
projects/app/src/components/Select/AIModelSelector.tsx
View file @
87e7c23d
...
@@ -205,6 +205,7 @@ const MultipleRowSelector = ({ list, onchange, disableTip, ...props }: Props) =>
...
@@ -205,6 +205,7 @@ const MultipleRowSelector = ({ list, onchange, disableTip, ...props }: Props) =>
list=
{
selectorList
}
list=
{
selectorList
}
onSelect=
{
onSelect
}
onSelect=
{
onSelect
}
value=
{
value
}
value=
{
value
}
rowMinWidth=
"160px"
ButtonProps=
{
{
ButtonProps=
{
{
isDisabled
:
!!
disableTip
isDisabled
:
!!
disableTip
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment