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

Fix issue 4593 #4807

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Yuchaocheng
Copy link
Collaborator

@Yuchaocheng Yuchaocheng commented Mar 29, 2024

close #4593

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

这是您为 Fusion/Next 提的第一个 pr,感谢您为 Fusion 做出的贡献,我们会尽快进行处理。

@eternalsky eternalsky self-requested a review April 30, 2024 02:28
@Yuchaocheng Yuchaocheng force-pushed the fix-issue-4593 branch 2 times, most recently from 0114ee1 to 88d6f6d Compare May 13, 2024 02:38
}, 500);
cy.mount(<Message animation={false} title="title" closeable />);
cy.get('.next-message-close').should('have.length', 1);
cy.clock();
Copy link
Contributor

Choose a reason for hiding this comment

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

clock,tick 都是没有必要的,get 本身就有延时获取的效果,done 也可以去掉。变成同步的 case 即可。

'Message'
);
cy.get('.next-message').should('have.length', 0);
cy.get<MountReturn>('@Message').then(({ component, rerender }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

这里可以用 cy.rerender 来简化写法,可以参考一下其他组件

expect($toast.get(0).innerText.trim()).to.eq(content);
expect($toast.get(0).offsetWidth).to.be.greaterThan(200);
});
cy.clock();
Copy link
Contributor

Choose a reason for hiding this comment

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

此处同上,所有的 clock ,tick 都可以去掉。

// access the native DOM element
expect($toast.get(0).innerText.trim()).to.eq('content');
});
cy.clock();
Copy link
Contributor

Choose a reason for hiding this comment

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

此处同上

});

it('should render message when only pass content string', done => {
Message.show('content');
assert(document.querySelector('.next-overlay-wrapper .next-message').innerText.trim() === 'content');

cy.get('.next-overlay-wrapper .next-message').should($toast => {
Copy link
Contributor

Choose a reason for hiding this comment

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

这里为什么不直接使用 should('have.text')


if (typeof config === 'string' || React.isValidElement(config)) {
newConfig.title = config;
} else if (obj.typeOf(config) === 'Object') {
newConfig = { ...config };
newConfig = { ...(config as MessageQuickProps) };
Copy link
Contributor

Choose a reason for hiding this comment

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

这里同上

| closeable | Whether to show the close button | boolean | false | |
| onClose | Callback function triggered when close | () => void | () =\> \{\} | |
| afterClose | Callback function triggered after closed | () => void | () =\> \{\} | |
| animation | Whether to enable expand and collapse animation | boolean | true | |

<!-- api-extra-start -->
Copy link
Contributor

Choose a reason for hiding this comment

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

Message.show 这次修改后,应该由 types 生成会比较合理一些,否则两边有可能会对不上。

@@ -96,7 +117,7 @@ export interface MessageQuickProps extends Omit<HTMLAttributesWeak, 'content'>,
/**
* 弹层相对于参照元素定位的微调
*/
offset?: Array<any>;
offset?: Array<number>;
Copy link
Contributor

Choose a reason for hiding this comment

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

MessageQuickProps 也应该以 Message.show 的形式透出到文档。

Copy link
Contributor

Choose a reason for hiding this comment

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

因此这里也应该补齐中英文和默认值

@@ -18,6 +18,8 @@ const MessageProvider = ConfigProvider.config(Message, {
});

export default MessageProvider;
export type { MessageProps, MessageQuickProps } from './types';
export type ContextMessage = typeof toast;
Copy link
Contributor

Choose a reason for hiding this comment

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

这个类型的导出感觉没有必要,typeof 是很容易得的。

animation: PropTypes.bool,
locale: PropTypes.object,
rtl: PropTypes.bool,
};
static show: Toast['show'];
Copy link
Contributor

Choose a reason for hiding this comment

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

这里其实没必要再这里多定义一遍,可以考虑在 index.tsx 中使用 assignSubComponent 进行输出。

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

Successfully merging this pull request may close these issues.

【Technical upgrade】Message
2 participants