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

Unable to disable mousePosition prop in Modal #11747

Closed
1 task done
cybercompa opened this issue Aug 15, 2018 · 2 comments
Closed
1 task done

Unable to disable mousePosition prop in Modal #11747

cybercompa opened this issue Aug 15, 2018 · 2 comments

Comments

@cybercompa
Copy link

cybercompa commented Aug 15, 2018

  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

3.8.1

Environment

Latest Chrome, MacOS, React.

Reproduction link

https://codepen.io/anon/pen/mjYJJw?editors=001

Steps to reproduce

If you pass mousePosition prop to a modal component you can see that it is not applied. In the case of a null value assigned to mousePosition, the animation should not appear.

What is expected?

mousePosition is respected as is laid out in the react-component/dialog documentation. As a user you should be able to set it to null if you do not wish for mousePosition to be used. The animation should be optional, but currently is forced for every modal opening based on the users mouse position coordinates.

What is actually happening?

Since specification order is important when using the spread operator, the later mousePosition prop overrides the previous one if passed in as a prop (see ...restProps) to the modal.

https://github.com/ant-design/ant-design/blob/master/components/modal/Modal.tsx

  render() {
    const { footer, visible, wrapClassName, centered, prefixCls, ...restProps } = this.props;

    const defaultFooter = (
      <LocaleReceiver
        componentName="Modal"
        defaultLocale={getConfirmLocale()}
      >
        {this.renderFooter}
      </LocaleReceiver>
    );

    return (
      <Dialog
        {...restProps}
        prefixCls={prefixCls}
        wrapClassName={classNames({ [`${prefixCls}-centered`]: !!centered }, wrapClassName)}
        footer={footer === undefined ? defaultFooter : footer}
        visible={visible}
        mousePosition={mousePosition}
        onClose={this.handleCancel}
      />
    );
  }
@cybercompa
Copy link
Author

cybercompa commented Aug 15, 2018

I believe dialog will also need to be updated to enforce this behavior as it uses a default transform-origin from the center.

@afc163
Copy link
Member

afc163 commented Aug 22, 2018

You can sending us a fixing PR but undocument it cause we don't hope someone to custom it.

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

2 participants