Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [BUG] ProFormSelect 中传递了默认值,但没有渲染在显示区域中 #11223

Closed
Locter9001 opened this issue May 2, 2024 · 1 comment

Comments

@Locter9001
Copy link

🐛 bug 描述

ProFormSelect 中传递了默认值,但没有渲染在显示区域中,并且显示区域是空的,连占位符都没有显示,这说明可能有值但没有被正确渲染

📷 复现步骤 | Recurrence steps

运行代码

🏞 期望结果 | Expected results

正确设置初始值

💻 复现代码 | Recurrence code

import { GetCategories } from '@/services/api/category';
import { SelectOptionType } from '@/typings';
import { ProFormSelect, ProFormSelectProps } from '@ant-design/pro-components';
import { BaseOptionType } from 'antd/es/select';
import React from 'react';

const ProformSelectCategory = <T, OptionType extends BaseOptionType = any>(
	props: ProFormSelectProps<T, OptionType>,
): React.ReactElement => {
	const fetchCategoryList = async ({ keyWords }: { keyWords: string; }): Promise<SelectOptionType[]> => {
		// if (!keyWords) return [];

		console.debug('<ProformSelectCategory> 搜索的关键字: ', keyWords, props.initialValue);

		try {
			const data = await GetCategories();
			return data.map((it): SelectOptionType => {
				return { label: it.name!, value: it.id!, key: it.id };
			});
		} catch (e) {
			console.debug('没有找到该分类');
			return [];
		}
	};

	return (
		<ProFormSelect<T, OptionType>
			fieldProps={{
				labelInValue: true,
			}}
			{...props}
			request={fetchCategoryList}
		/>
	);
};

export default ProformSelectCategory;

© 版本信息

  • Ant Design Pro 版本: 2.6.48
  • umi 版本 2.2.2
  • 浏览器环境 Edge
  • 开发环境 Windows Edge

🚑 其他信息

image

Copy link

github-actions bot commented May 2, 2024

当前 Issue 未检测到标题,请规范填写,谢谢!

The title of the current issue is not detected, please fill in according to the specifications, thank you!

@github-actions github-actions bot closed this as completed May 2, 2024
@Locter9001 Locter9001 changed the title 🐛 [BUG] 🐛 [BUG] ProFormSelect 中传递了默认值,但没有渲染在显示区域中 May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant