Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the bug of slow emoji rendering on mac chrome #900

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/emoji-mart/src/components/Picker/Picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Component, createRef } from 'preact'

import { deepEqual, sleep, getEmojiData } from '../../utils'
import { Data, I18n, init } from '../../config'
import { SearchIndex, Store, FrequentlyUsed } from '../../helpers'
import { SearchIndex, Store, FrequentlyUsed, UserAgent } from '../../helpers'
import Icons from '../../icons'

import { Emoji } from '../Emoji'
Expand Down Expand Up @@ -776,6 +776,12 @@ export default class Picker extends Component {
height: this.props.emojiButtonSize,
fontSize: this.props.emojiSize,
lineHeight: 0,
backfaceVisibility:
UserAgent.isMacOs &&
UserAgent.chromeVersion > 0 &&
UserAgent.chromeVersion < 121
? 'hidden'
: undefined,
}}
>
<div
Expand Down
1 change: 1 addition & 0 deletions packages/emoji-mart/src/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export { default as Store } from './store'
export { default as NativeSupport } from './native-support'
export { default as FrequentlyUsed } from './frequently-used'
export { default as SearchIndex } from './search-index'
export { default as UserAgent } from './user-agent'

export const SafeFlags = [
'checkered_flag',
Expand Down
13 changes: 13 additions & 0 deletions packages/emoji-mart/src/helpers/user-agent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const agent: string = window.navigator.userAgent.toLowerCase()

const isMacOs: boolean = agent.indexOf('mac') !== -1
const isChrome: boolean = agent.indexOf('chrome') > -1
const chromeVersion: number = isChrome
? parseInt(agent.match(/chrome\/(\d+)/i)[1])
: 0

export default {
isMacOs,
isChrome,
chromeVersion,
}
Loading