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

在nextjs13中onOpenChange可以改变openkeys,但是改变后,菜单不能收起 #621

Open
ideaviewes opened this issue Apr 16, 2023 · 0 comments

Comments

@ideaviewes
Copy link

ideaviewes commented Apr 16, 2023

代码如下

  const renderTable = (nodes: TableItem[]) => {
    return nodes.map((item) => {
      if (!item.children) {
        return (
          <MenuItem
            className={'flex h-10 items-center rounded-md text-sm hover:bg-gray-100'}
            key={item.key}
          >
            {item.label}
          </MenuItem>
        );
      }
      return (
        <SubMenu
          className={'cursor-pointer text-sm'}
          key={item.key}
          title={
            <div className={'flex h-10 items-center justify-between rounded-md text-sm'}>
              {item.label}
            </div>
          }
        >
          {renderTable(item.children)}
        </SubMenu>
      );
    });
  };

  const [openKeys, handleOpenKeys] = useState<string[]>([]);
  const onOpenChange = (openKeys: string[]) => {
    handleOpenKeys(openKeys);
  };

          <Menu
            className={'doc-table w-full px-2'}
            mode={'inline'}
            openKeys={openKeys}
            onOpenChange={onOpenChange}
          >
            {renderTable(items)}
          </Menu>

可以打开子菜单,但是关闭不了,点击的时候,打印可以看到openKeys已经发生了改变,但是子菜单还是收不回去

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