Skip to content

Commit

Permalink
Merge pull request missive#329 from missive/fix-emoji-button
Browse files Browse the repository at this point in the history
fix: use span for non-clickable emojis
  • Loading branch information
EtienneLem authored Mar 28, 2019
2 parents abc2cda + 7f05e22 commit 9b3a448
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/components/__tests__/__snapshots__/not-found.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Renders <NotFound> component 1`] = `
<div
className="emoji-mart-no-results"
>
<button
<span
aria-label="🕵️, sleuth_or_spy"
className="emoji-mart-emoji emoji-mart-emoji-native"
onClick={[Function]}
Expand All @@ -25,7 +25,7 @@ exports[`Renders <NotFound> component 1`] = `
>
🕵️
</span>
</button>
</span>
<div
className="emoji-mart-no-results-label"
>
Expand Down
21 changes: 17 additions & 4 deletions src/components/emoji/nimble-emoji.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,23 +177,36 @@ const NimbleEmoji = (props) => {
}
}

var Tag = {
name: 'span',
props: {},
}

if (props.onClick) {
Tag.name = 'button'
Tag.props = {
type: 'button',
}
}

if (props.html) {
style = _convertStyleToCSS(style)
return `<button style='${style}' aria-label='${label}' ${
return `<${Tag.name} style='${style}' aria-label='${label}' ${
title ? `title='${title}'` : ''
} class='${className}'>${children || ''}</button>`
} class='${className}'>${children || ''}</${Tag.name}>`
} else {
return (
<button
<Tag.name
onClick={(e) => _handleClick(e, props)}
onMouseEnter={(e) => _handleOver(e, props)}
onMouseLeave={(e) => _handleLeave(e, props)}
aria-label={label}
title={title}
className={className}
{...Tag.props}
>
<span style={style}>{children}</span>
</button>
</Tag.name>
)
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/utils/shared-default-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ const EmojiDefaultProps = {
tooltip: false,
backgroundImageFn: (set, sheetSize) =>
`https://unpkg.com/emoji-datasource-${set}@${EMOJI_DATASOURCE_VERSION}/img/${set}/sheets-256/${sheetSize}.png`,
onOver: () => {},
onLeave: () => {},
onClick: () => {},
}

const PickerDefaultProps = {
Expand Down

0 comments on commit 9b3a448

Please sign in to comment.