Skip to content

Commit

Permalink
fix(Message): The styles of the outer Message component will affect t…
Browse files Browse the repository at this point in the history
…he inner component when nested, close #4851
  • Loading branch information
wangw11056 authored and eternalsky committed Jul 1, 2024
1 parent cce7196 commit ec8978e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
29 changes: 29 additions & 0 deletions components/message/__tests__/issue-spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,33 @@ describe('Message issues', () => {
expect(iconPos.y).to.equal(contentPos.y);
});
});

// Fix: https://github.com/alibaba-fusion/next/issues/4851
it('The styles of the outer Message component will affect the inner component when nested', () => {
cy.mount(
<Message type="help">
<Message type="error">
<span>help</span>
</Message>
</Message>
);
cy.get('.next-message-help').should('have.length', 1);
cy.get('.next-message-error').should('have.length', 1);

cy.get('.next-message-help .next-message-symbol-icon').then($el => {
expect($el.css('color')).to.equal('rgb(1, 193, 178)');
const element = $el[0];
const helpIconCode = window.getComputedStyle(element, '::before').content;
console.log(helpIconCode.charCodeAt(1).toString(16));
expect(helpIconCode.charCodeAt(1).toString(16)).to.equal('e673');
});

cy.get('.next-message-error .next-message-symbol-icon').then($el => {
expect($el.css('color')).to.equal('rgb(255, 48, 0)');
const element = $el[0];
const errorIconCode = window.getComputedStyle(element, '::before').content;
console.log(errorIconCode.charCodeAt(1).toString(16));
expect(errorIconCode.charCodeAt(1).toString(16)).to.equal('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 ec8978e

Please sign in to comment.