Skip to content

Commit

Permalink
fix(layout): if src=null, un render avatar
Browse files Browse the repository at this point in the history
close #7520
  • Loading branch information
chenshuai2144 committed Aug 13, 2023
1 parent b5d9eff commit c721e07
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/layout/src/components/SiderMenu/SiderMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ const SiderMenu: React.FC<SiderMenuProps & PrivateSiderMenuProps> = (props) => {
const { title, render, ...rest } = avatarProps;
const dom = (
<div className={`${baseClassName}-actions-avatar`}>
<Avatar size={28} {...rest} />
{rest?.src || rest?.srcSet ? <Avatar size={28} {...rest} /> : null}
{avatarProps.title && !collapsed && <span>{title}</span>}
</div>
);
Expand Down
32 changes: 30 additions & 2 deletions tests/field/__snapshots__/demo.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4340,7 +4340,12 @@ exports[`field demos 📸 renders ./packages/field/src/demos/base_test.tsx corre
<textarea
class="ant-input"
rows="5"
/>
>
yarn run v1.22.0
$ eslint --format=pretty ./packages
Done in 9.70s.
</textarea>
</span>
</div>
</td>
Expand All @@ -4366,7 +4371,30 @@ exports[`field demos 📸 renders ./packages/field/src/demos/base_test.tsx corre
<textarea
class="ant-input"
rows="5"
/>
>
{
"compilerOptions": {
"target": "esnext",
"moduleResolution": "node",
"jsx": "preserve",
"esModuleInterop": true,
"experimentalDecorators": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"declaration": true,
"skipLibCheck": true
},
"include": [
"**/src",
"**/docs",
"scripts",
"**/demo",
".eslintrc.js"
]
}
</textarea>
</span>
</div>
</td>
Expand Down
61 changes: 57 additions & 4 deletions tests/field/__snapshots__/field.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,12 @@ exports[`Field 🐴 edit and no plain 1`] = `
<textarea
class="ant-input"
rows="5"
/>
>
yarn run v1.22.0
$ eslint --format=pretty ./packages
Done in 9.70s.
</textarea>
</span>
</div>
</td>
Expand All @@ -1255,7 +1260,30 @@ exports[`Field 🐴 edit and no plain 1`] = `
<textarea
class="ant-input"
rows="5"
/>
>
{
"compilerOptions": {
"target": "esnext",
"moduleResolution": "node",
"jsx": "preserve",
"esModuleInterop": true,
"experimentalDecorators": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"declaration": true,
"skipLibCheck": true
},
"include": [
"**/src",
"**/docs",
"scripts",
"**/demo",
".eslintrc.js"
]
}
</textarea>
</span>
</div>
</td>
Expand Down Expand Up @@ -2421,7 +2449,11 @@ exports[`Field 🐴 edit and plain=true 1`] = `
<input
class="ant-input"
type="text"
value=""
value="
yarn run v1.22.0
$ eslint --format=pretty ./packages
Done in 9.70s.
"
/>
</span>
</div>
Expand All @@ -2444,7 +2476,28 @@ exports[`Field 🐴 edit and plain=true 1`] = `
<input
class="ant-input"
type="text"
value=""
value="{
"compilerOptions": {
"target": "esnext",
"moduleResolution": "node",
"jsx": "preserve",
"esModuleInterop": true,
"experimentalDecorators": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"suppressImplicitAnyIndexErrors": true,
"declaration": true,
"skipLibCheck": true
},
"include": [
"**/src",
"**/docs",
"scripts",
"**/demo",
".eslintrc.js"
]
}"
/>
</span>
</div>
Expand Down
12 changes: 9 additions & 3 deletions tests/layout/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ exports[`BasicLayout 🥩 BasicLayout menu support menu.true 1`] = `
<ul
class="ant-skeleton-paragraph"
>
<li />
<li
style=""
/>
<li />
<li />
<li />
Expand Down Expand Up @@ -444,7 +446,9 @@ exports[`BasicLayout 🥩 BasicLayout menu support menu.true 1`] = `
<ul
class="ant-skeleton-paragraph"
>
<li />
<li
style=""
/>
<li />
<li />
<li />
Expand Down Expand Up @@ -1562,7 +1566,9 @@ exports[`BasicLayout 🥩 support loading 1`] = `
<ul
class="ant-skeleton-paragraph"
>
<li />
<li
style=""
/>
<li />
<li />
<li />
Expand Down

0 comments on commit c721e07

Please sign in to comment.