Skip to content

fix: upload data model Collapse state #32734

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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ const UploadDataModal: FunctionComponent<UploadDataModalProps> = ({
useState<boolean>(false);
const [previewUploadedFile, setPreviewUploadedFile] = useState<boolean>(true);
const [fileLoading, setFileLoading] = useState<boolean>(false);
const [activeKey, setActiveKey] = useState<string | string[]>('general');

const createTypeToEndpointMap = (databaseId: number) =>
`/api/v1/database/${databaseId}/upload/`;
Expand Down Expand Up @@ -539,6 +540,13 @@ const UploadDataModal: FunctionComponent<UploadDataModalProps> = ({
}
}, [delimiter]);

// Reset active panel to 'general' when modal is shown
useEffect(() => {
if (show) {
setActiveKey('general');
}
}, [show]);
Comment on lines +544 to +548

This comment was marked as resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

documentation for show effect added

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job on adding the documentation for the show effect. It would be more helpful if there was more detail about what the show effect is and why resetting activeKey is necessary when show changes. The name show effect is a little ambiguous without additional context, so it could be useful to include this in the comment.


const validateUpload = (_: any, value: string) => {
if (fileList.length === 0) {
return Promise.reject(t('Uploading a file is required'));
Expand Down Expand Up @@ -600,7 +608,8 @@ const UploadDataModal: FunctionComponent<UploadDataModalProps> = ({
<Collapse
expandIconPosition="right"
accordion
defaultActiveKey="general"
activeKey={activeKey}
onChange={key => setActiveKey(key)}
css={(theme: SupersetTheme) => antdCollapseStyles(theme)}
>
<Collapse.Panel
Expand Down
Loading