Skip to content

[Bug] [DataStudio] The "create root directory" modal pops up again after the creation succeeds #4576

Closed as not planned

Description

@gallant-oliver

Search before asking

  • I had searched in the issues and found no similar issues.

What happened

In DataStudio (数据开发), when creating a root directory, after entering the name and clicking OK, the directory is created successfully and the project tree refreshes — but the create root directory modal immediately pops up again. If the user clicks OK once more, it tries to create a duplicate directory and fails with a duplicate-name error.

The same code is still present in current master.

Root cause — dinky-web/src/pages/DataStudio/Toolbar/Project/index.tsx:

The effect that handles actionType has the dependency array [actionType, params, data, treeData], and its PROJECT_CREATE_ROOT_DIR branch only calls setOpenCreateRootDir(true) without resetting the action afterwards:

useEffect(() => {
  if (!data) { return; }
  switch (actionType) {
    case DataStudioActionType.PROJECT_CREATE_ROOT_DIR:
      setOpenCreateRootDir(true);
      break;
    ...
  }
}, [actionType, params, data, treeData]);

After a successful creation, handleCreateRootDirSubmit calls refresh(). When the refreshed tree data arrives, data changes and the effect re-runs. Since actionType is still PROJECT_CREATE_ROOT_DIR, setOpenCreateRootDir(true) executes again and the modal reopens.

For comparison, Toolbar/Catalog/index.tsx resets the action after handling it:

if (actionType === DataStudioActionType.CATALOG_REFRESH) {
  await refreshMetaStoreTables();
  updateAction({ actionType: null, params: null });
}

What you expected to happen

After the root directory is created successfully, the modal should close and stay closed; the refreshed tree simply shows the new directory.

How to reproduce

  1. Open the web UI → DataStudio (数据开发)
  2. Click the 新建目录 (create root directory) button at the top-left of the project panel
  3. Enter a name and click OK / 确认
  4. The modal closes and the tree refreshes, then the same create-root-directory modal opens again
  5. (Optional) Click OK again → the backend rejects it with a duplicate-name error

Anything else

  • Frequency: happens every time when creating a root directory.
  • Possible fix: reset the action after handling it (updateAction({ actionType: null, params: null })), or move the action handling into an effect keyed only on [actionType].

Version

1.2.5 (also reproduced in master source code)


中文描述(补充):数据开发页面新建根目录,点击确认创建成功后,新建目录弹窗会再次弹出。原因:Project/index.tsx 中处理 actionType 的 useEffect 依赖了 [actionType, params, data, treeData],PROJECT_CREATE_ROOT_DIR 分支只打开弹窗但没有重置 action;创建成功后 refresh() 刷新目录树,data 变化导致 effect 重新执行,而 actionType 仍是 PROJECT_CREATE_ROOT_DIR,弹窗因此被再次打开。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions