Skip to content

Commit

Permalink
fix(Message): Style override problem when Message components are nest…
Browse files Browse the repository at this point in the history
…ed in each other, close alibaba-fusion#4851
  • Loading branch information
wangw11056 committed Jun 4, 2024
1 parent 42c5c8f commit ea78fd3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
28 changes: 28 additions & 0 deletions components/message/__tests__/issue-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,32 @@ describe('Message issues', () => {
assert(iconPos.height === contentPos.height);
assert(iconPos.y === contentPos.y);
});

// Fix: https://github.com/alibaba-fusion/next/issues/4851
it('should be rendered correctly styles when Message components are nested within each other', () => {
wrapper = render(
<Message type="help">
<Message type="error">
<span>help</span>
</Message>
</Message>
);
assert(wrapper.find('.next-message-help').length === 1);
assert(wrapper.find('.next-message-error').length === 1);

const helpIcon = wrapper.find('.next-message-help .next-message-symbol-icon')[0];
const errorIcon = wrapper.find('.next-message-error .next-message-symbol-icon')[0];
assert(helpIcon);
assert(errorIcon);

const helpIconStyles = window.getComputedStyle(helpIcon);
const errorIconStyles = window.getComputedStyle(errorIcon);
assert(helpIconStyles.color === 'rgb(1, 193, 178)');
assert(errorIconStyles.color === 'rgb(255, 48, 0)');

const helpIconCode = window.getComputedStyle(helpIcon, '::before').content;
const errorIconCode = window.getComputedStyle(errorIcon, '::before').content;
assert(helpIconCode.charCodeAt(1).toString(16) === 'e673');
assert(errorIconCode.charCodeAt(1).toString(16) === 'e60d');
});
});
8 changes: 4 additions & 4 deletions components/message/scss/mixin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,16 @@
border-color: $borderColor;
box-shadow: $shadow;

.#{$css-prefix}message-title {
> .#{$css-prefix}message-title {
color: $titleColor;
}
.#{$css-prefix}message-content {
> .#{$css-prefix}message-content {
color: $contentColor;
}
.#{$css-prefix}message-symbol {
> .#{$css-prefix}message-symbol {
color: $iconColor;
}
.#{$css-prefix}message-symbol-icon::before {
> .#{$css-prefix}message-symbol-icon::before {
vertical-align: top;
content: $icon;
@if (get-compiling-value($icon) == get-compiling-value($message-loading-icon-content)) {
Expand Down

0 comments on commit ea78fd3

Please sign in to comment.