Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1ed0092
fix: Add TypeScript definitions (#223)
ellinge Mar 31, 2019
f8eb1c3
fix: Typing error for children (#232)
ellinge Apr 2, 2019
cb38633
fix: Prevent dropdown close on expand in Firefox (#231)
ellinge Apr 3, 2019
bdf47bc
docs: Add types friendly badge 📚 (#229)
mrchief Apr 13, 2019
7ae71bb
style: Auto format code using prettier before commit (#224)
mrchief Apr 13, 2019
b3e7ec9
feat: Added support for single select in tree dropdown (#217)
ellinge Apr 18, 2019
ef6e584
Add Breaking change to allowed prefixes
mrchief Apr 22, 2019
4e1d5af
feat: Ability to keep the dropdown open always (#241) ✨
moonjy1993 Apr 23, 2019
a4fb879
feat: Add keyboard navigation (#225)
ellinge May 1, 2019
3e5381e
feat: Add ARIA roles and attributes (#233)
gazab May 3, 2019
4806c8e
docs: add moonjy1993 as a contributor (#246)
allcontributors[bot] May 4, 2019
cbd256d
docs: add gazab as a contributor (#247)
allcontributors[bot] May 4, 2019
1f24344
fix: Remove babel-runtime from distribution bundle (#248) 🔥
mrchief May 6, 2019
fb5beb3
Merge branch 'master' into develop
mrchief Apr 18, 2019
764a002
fix: Updated onAction to bubble up custom props (#230)
ellinge May 9, 2019
1657711
test: Update ava to produce consistent snapshots across OSes 🚨 (#250)
mrchief May 9, 2019
007602b
feat: Group logically related props together (#242) ⚡️
ellinge May 9, 2019
637fe66
refactor: Update mode to include hierarchical (#251)
mrchief May 12, 2019
60624a4
chore: Update PULL_REQUEST_TEMPLATE.md
mrchief May 21, 2019
a943bea
style: Consistent formatting of code in example comment
Jun 4, 2019
655c45a
refactor: Consolidate showDropdown props (#253) 🔨️
mrchief Jun 10, 2019
70bdd04
fix: Avoid jarring on paging (#259)
ellinge Jun 10, 2019
32c0da1
Merge branch 'develop'
mrchief Jun 10, 2019
af2dedf
fix: Don't reset current true-state for showDropdown
Jun 14, 2019
965efbc
fix: Store as bool
Jun 14, 2019
fee3aca
Merge branch 'develop' into fix/RemoveResettingOnDropdownOnInitProps
mrchief Jun 15, 2019
f37a46c
fix: Adds tests
ellinge Jun 15, 2019
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
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ class DropdownTreeSelect extends Component {
if (currentFocusNode) {
currentFocusNode._focused = true
}
this.setState({
showDropdown: /initial|always/.test(showDropdown) || false,
this.setState(prevState => ({
showDropdown: /initial|always/.test(showDropdown) || prevState.showDropdown === true,
...this.treeManager.getTreeAndTags(),
})
}))
}

resetSearchState = () => {
Expand Down
22 changes: 22 additions & 0 deletions src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,28 @@ test('toggles dropdown', t => {
t.false(wrapper.state().showDropdown)
})

test('keeps dropdown open on props update', t => {
const { tree } = t.context
const wrapper = mount(<DropdownTreeSelect data={tree} />)
wrapper.instance().handleClick()
t.true(wrapper.state().showDropdown)
wrapper.setProps({ data: tree })
t.true(wrapper.state().showDropdown)
})

test('opens dropdown on props update with show intention', t => {
const { tree } = t.context
const wrapper = mount(<DropdownTreeSelect data={tree} />)
t.false(wrapper.state().showDropdown)
wrapper.setProps({ data: tree, showDropdown: 'initial' })
t.true(wrapper.state().showDropdown)
wrapper.instance().handleClick()
t.false(wrapper.state().showDropdown)
wrapper.setProps({ data: tree, showDropdown: 'always' })
wrapper.instance().handleClick()
t.true(wrapper.state().showDropdown)
})

test('sets unique ids on dropdowns', t => {
const { tree } = t.context
clientIdGenerator.reset()
Expand Down