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

Drawer 打开一个很卡的页面,会卡住没有任何反应需要子页面渲染完了才会展开。 #8723

Open
echoyl opened this issue Sep 7, 2024 · 4 comments

Comments

@echoyl
Copy link
Contributor

echoyl commented Sep 7, 2024

Reproduction link

Edit on StackBlitz

Steps to reproduce

点击open按钮,大概过个3秒才会展开

What is expected?

可以先展开drawer然后里面loading,渲染好了后再展示内容。

What is actually happening?

卡住了

Environment Info
antd 5.20.5
React 18.3.1
System windows
Browser chrome版本 113.0.5672.127(正式版本) (64 位)

如果使用自带loading属性,貌似也是设置了false后子组件才会真正开始渲染,时间还是不变的

Copy link

stackblitz bot commented Sep 7, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@LLmoskk
Copy link

LLmoskk commented Sep 9, 2024

@echoyl
image
可以添加loading 来直接打开drawer 在antd 5.17.0以上 官网有个示例

@echoyl
Copy link
Contributor Author

echoyl commented Sep 9, 2024

@echoyl image 可以添加loading 来直接打开drawer 在antd 5.17.0以上 官网有个示例

这个方法没用。现在我就是

setTimeout(() => {
        setLoading(false);
      }, 10);

先打开drawer再说。虽然也是卡住了,比之前点击按钮没有任何反应的卡住要好一点

@Wxh16144
Copy link
Member

Wxh16144 commented Sep 9, 2024

先打开drawer再说。虽然也是卡住了,比之前点击按钮没有任何反应的卡住要好一点

没用过 pro-components 居然能有这么卡,加一个 flag, 抽屉打开后再挂载你的内容。比如(不完全正确)

const App = () => {
  const [open, setOpen] = useState(false);
  const [shouldMount, setShouldMount] = useState(false);


  const showDrawer = () => {
    setOpen(true);
  };

  const onClose = () => {
    setOpen(false);
    setShouldMount(false);
  };

  const CAN_USE = !!shouldMount

  return (
    <>
      <Button type="primary" onClick={showDrawer}>
        Open
      </Button>
      <Drawer
        title="Basic Drawer"
        loading={CAN_USE === false}
        maskClosable={CAN_USE}
        keyboard={CAN_USE}
        closeIcon={CAN_USE}
        // mask={CAN_USE}
        afterOpenChange={v => {
          console.log('afterOpenChange', v);
          if (v) {
            setShouldMount(true)
          }
        }}

        onClose={onClose}
        open={open}
        width={1500}

      >
        {
          shouldMount
            ? (
              <ProForm
                request={async () => {
                  return { columns: [...value, ...value] };
                }}
                variant="filled"
                grid={true}
              >
                <BetaSchemaForm layoutType="Embed" columns={fieldColumns} />
              </ProForm>
            )
            : null
        }
      </Drawer>
    </>
  );
};

export default App

@MadCcc MadCcc transferred this issue from ant-design/ant-design Sep 11, 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

3 participants