Skip to content

fix(Modal): replace deprecated maskClosable with mask.closable#481

Open
hugetiny wants to merge 1 commit intolobehub:masterfrom
hugetiny:fix/maskClosable-deprecation
Open

fix(Modal): replace deprecated maskClosable with mask.closable#481
hugetiny wants to merge 1 commit intolobehub:masterfrom
hugetiny:fix/maskClosable-deprecation

Conversation

@hugetiny
Copy link

@hugetiny hugetiny commented Mar 2, 2026

Description

Replace deprecated maskClosable prop with mask={{ closable: ... }} to fix antd 6.x deprecation warning.

Changes

  • src/Modal/Modal.tsx: Replace maskClosable prop with mask={{ closable: true }}
  • src/Modal/RawModalStackItem.tsx: Update onUpdate call to use new format
  • src/Modal/ModalStackItem.tsx: Update onUpdate call to use new format
  • src/Modal/imperative.tsx: Update updateModal and updateRawProps calls

Related Issue

Fixes #480

Testing

  • Verified no more "maskClosable is deprecated" warnings in console
  • Modal click-outside-to-dismiss functionality still works

Thanks for maintaining this great library! 🙏

Replace deprecated maskClosable prop with mask={{ closable: ... }}
to fix antd 6.x deprecation warning.

Files changed:
- src/Modal/Modal.tsx
- src/Modal/RawModalStackItem.tsx
- src/Modal/ModalStackItem.tsx
- src/Modal/imperative.tsx

Fixes lobehub#480
Copilot AI review requested due to automatic review settings March 2, 2026 17:19
@vercel
Copy link

vercel bot commented Mar 2, 2026

Someone is attempting to deploy a commit to the LobeHub OSS Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Sorry @hugetiny, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@lobehubbot
Copy link
Member

👍 @hugetiny


Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Modal implementation to align with Ant Design 6.x by replacing the deprecated maskClosable prop with the new mask={{ closable: ... }} API, removing the related deprecation warning while preserving click-outside-to-dismiss behavior.

Changes:

  • Replace maskClosable usage in Modal with mask={{ closable: true }}
  • Update the imperative/stack update flows to toggle dismiss-on-mask-click via mask.closable
  • Propagate the new mask update shape through modal stack items and imperative APIs

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/Modal/Modal.tsx Switches internal Ant Modal config from maskClosable to mask.closable.
src/Modal/RawModalStackItem.tsx Updates stack-item onUpdate payload to use mask.closable.
src/Modal/ModalStackItem.tsx Updates stack-item onUpdate payload to use mask.closable.
src/Modal/imperative.tsx Updates imperative APIs to toggle dismiss-on-outside-click via mask.closable.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const close = useEventCallback(() => onClose(id));
const setCanDismissByClickOutside = useEventCallback((value: boolean) =>
onUpdate(id, { maskClosable: value }),
onUpdate(id, { mask: { closable: value } }),
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

onUpdate ultimately shallow-merges modal props in updateModal. Passing mask: { closable: value } here will overwrite any existing mask configuration on the imperative modal (dropping other mask fields). Consider updating the merge logic (or this update payload) so only mask.closable is changed while preserving other mask properties.

Copilot uses AI. Check for mistakes.

const setCanDismissByClickOutside = useEventCallback((value: boolean) => {
onUpdate(id, { maskClosable: value });
onUpdate(id, { mask: { closable: value } });
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

onUpdate shallow-merges raw props; sending mask: { closable: value } will replace any existing mask object and can drop other mask-related settings. Consider merging with the existing mask object (when it’s an object) so this toggle only affects mask.closable.

Suggested change
onUpdate(id, { mask: { closable: value } });
const currentMask = props['mask'];
const nextMask =
currentMask && typeof currentMask === 'object'
? { ...(currentMask as Record<string, unknown>), closable: value }
: { closable: value };
onUpdate(id, { mask: nextMask });

Copilot uses AI. Check for mistakes.
close: () => closeModal(id),
destroy: () => destroyModal(id),
setCanDismissByClickOutside: (value) => updateModal(id, { maskClosable: value }),
setCanDismissByClickOutside: (value) => updateModal(id, { mask: { closable: value } }),
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

updateModal only does a shallow merge (props: { ...item.props, ...nextProps }). Updating mask with { closable: value } will overwrite any existing mask config (e.g., styles, className, motion) that may have been provided when creating/updating the modal. Consider merging with the existing props.mask (when it’s an object) so setCanDismissByClickOutside only changes mask.closable without dropping other fields.

Copilot uses AI. Check for mistakes.
close: () => closeModal(id),
destroy: () => destroyModal(id),
setCanDismissByClickOutside: (value) => updateRawProps(id, { maskClosable: value }),
setCanDismissByClickOutside: (value) => updateRawProps(id, { mask: { closable: value } }),
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

updateRawProps performs a shallow merge, so setting mask: { closable: value } will replace any existing mask object in the raw modal props. If callers provided additional mask options, setCanDismissByClickOutside will unintentionally drop them. Consider merging mask objects (when applicable) instead of overwriting.

Copilot uses AI. Check for mistakes.
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

Successfully merging this pull request may close these issues.

[Bug] Modal component triggers antd deprecation warning: maskClosable is deprecated

3 participants