mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: fix selectedKeys
This commit is contained in:
1 file changed
+2
-1
+2
-1
@@ -11,11 +11,12 @@ const LanguageSelectAutoComplete = React.forwardRef<any, any>((props, ref) => (
|
|||||||
<CustomSelectAutoComplete
|
<CustomSelectAutoComplete
|
||||||
ref={ref as any}
|
ref={ref as any}
|
||||||
{...props}
|
{...props}
|
||||||
|
selectedKeys={typeof props.selectedKeys === 'string' ? props.selectedKeys.split(',') : props.selectedKeys}
|
||||||
data={props.withAuto ? withAuto : data}
|
data={props.withAuto ? withAuto : data}
|
||||||
renderItem={(item) => (prefixes.has(item._id) ? '' : `${item.name}`)}
|
renderItem={(item) => (prefixes.has(item._id) ? '' : `${item.name}`)}
|
||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
let value = val.split(',');
|
let value = val.split(',');
|
||||||
const active = new Set(value.filter((i) => i.includes('.').map((i) => i.split('.')[0])));
|
const active = new Set(value.filter((i) => i.includes('.')).map((i) => i.split('.')[0]));
|
||||||
value = value.filter((i) => !prefixes.has(i) || active.has(i));
|
value = value.filter((i) => !prefixes.has(i) || active.has(i));
|
||||||
for (const i of active) if (!value.includes(i)) value.push(i);
|
for (const i of active) if (!value.includes(i)) value.push(i);
|
||||||
props.onChange(value.join(','));
|
props.onChange(value.join(','));
|
||||||
|
|||||||
Reference in new issue
Block a user