Skip to content

Commit

Permalink
Merge pull request #250 from ritchiejacobs/fix/allow-empty-alt-title
Browse files Browse the repository at this point in the history
fix(image): allow empty string for alt and title property
  • Loading branch information
JorgenEvens authored Aug 5, 2022
2 parents dc76a58 + f543221 commit af9f8cb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ export interface ReactAvatarProps {
/**
* The alt attribute used on the avatar img tag. If not set we will fallback to either name or value
*/
alt?: string;
alt?: string | boolean;
/**
* The title attribute used on the avatar img tag. If not set we will fallback to either name or value
*/
title?: string;
title?: string | boolean;
/**
* Used in combination with `name` and `value`. Give the background a fixed color with a hex like for example #FF0000
*/
Expand Down
5 changes: 4 additions & 1 deletion src/components/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ export default
class AvatarImage extends React.PureComponent {

static propTypes = {
alt: PropTypes.string,
alt: PropTypes.oneOfType([
PropTypes.string,
PropTypes.bool
]),
title: PropTypes.oneOfType([
PropTypes.string,
PropTypes.bool
Expand Down
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ function setGroupedTimeout(fn, ttl) {
export
function getNullableText(...args) {
for (const arg of args) {
if (arg)
if (arg || arg === '')
return arg;

if (arg === false || arg === null)
Expand Down

0 comments on commit af9f8cb

Please sign in to comment.