Skip to content

Commit

Permalink
clean up + update test
Browse files Browse the repository at this point in the history
  • Loading branch information
Xindi Xu committed Jul 21, 2020
1 parent 7eae6f1 commit 81d109a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/components/__tests__/skins-dot.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { shallow, configure } from 'enzyme'
import { mount, configure } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
import SkinsDot from '../skins-dot'

Expand All @@ -21,7 +21,7 @@ test('click dot to expand the menu', () => {
},
}

const skins = shallow(<SkinsDot skin={1} onChange={onChange} i18n={i18n} />)
const skins = mount(<SkinsDot skin={1} onChange={onChange} i18n={i18n} />)

// component should be un-expanded by default
expect(skins.find('[aria-haspopup]').prop('aria-label')).toEqual(
Expand Down
9 changes: 3 additions & 6 deletions src/components/picker/nimble-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,12 +634,9 @@ class NimblePicker extends React.PureComponent {
const activeCategoryIndex = this.categories.findIndex(
({ name }) => name === activeCategory,
)
const { container } = this.categoryRefs[
`category-${activeCategoryIndex}`
]

const firstEmoji = container.querySelector('button')
firstEmoji.focus()
const emojiEl = this.getEmojiElement(activeCategoryIndex, 0)
emojiEl.focus()
this.getEmojiToPreview(activeCategoryIndex, 0)
handled = true
break

Expand Down
5 changes: 3 additions & 2 deletions src/components/skins-dot.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@ export default class SkinsDot extends Skins {
if (opened) {
this.handleClick(e)
this.onClose(e)
} else {
this.handleMenuClick(e)
}
}}
onKeyDown={(e) => this.handleSkinKeyDown(e, skinTone)}
tabIndex={opened ? '0' : '-1'}
tabIndex={selected ? '0' : '-1'}
role="button"
{...(selected
? {
Expand All @@ -138,7 +140,6 @@ export default class SkinsDot extends Skins {
<div
{...(opened ? { role: 'menubar' } : {})}
tabIndex={'0'}
onClick={this.handleMenuClick}
onKeyDown={this.handleKeyDown}
ref={this.setSkinTonesRef}
>
Expand Down
18 changes: 7 additions & 11 deletions stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,13 @@ storiesOf('Picker', module)
/>
))

.add('Custom “Not found” component', () => {
const ref = useRef(null)
return (
<Picker
ref={ref}
notFound={() => (
<img src="https://github.githubassets.com/images/icons/emoji/octocat.png" />
)}
/>
)
})
.add('Custom “Not found” component', () => (
<Picker
notFound={() => (
<img src="https://github.githubassets.com/images/icons/emoji/octocat.png" />
)}
/>
))

.add('Custom categories', () => (
<Picker custom={CUSTOM_EMOJIS_WITH_CATEGORIES} />
Expand Down

0 comments on commit 81d109a

Please sign in to comment.