Skip to content

Commit df68ee2

Browse files
authored
Merge branch 'develop' into feat/focus-first-match
2 parents 5c8daf6 + 92698cb commit df68ee2

File tree

8 files changed

+197
-44
lines changed

8 files changed

+197
-44
lines changed

Diff for: .all-contributorsrc

+12-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,18 @@
273273
"contributions": [
274274
"code"
275275
]
276+
},
277+
{
278+
"login": "kYem",
279+
"name": "Kestutis Kasiulynas",
280+
"avatar_url": "https://avatars1.githubusercontent.com/u/3390897?v=4",
281+
"profile": "http://kYem.net",
282+
"contributions": [
283+
"bug",
284+
"code"
285+
]
276286
}
277287
],
278-
"contributorsPerLine": 7
288+
"contributorsPerLine": 7,
289+
"skipCi": true
279290
}

Diff for: .github/workflows/ci.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [develop, master]
6+
pull_request:
7+
branches: [develop]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Setup Node JS
16+
uses: actions/setup-node@v1
17+
with:
18+
node-version: 12.x
19+
- run: yarn install --ignore-engines
20+
- run: yarn lint:nofix
21+
# 💀💀💀💀cannot run coveralls since GH won't pass COVERALLS_REPO_TOKEN to forks; so any PRs from external contributors would fail
22+
# - run: yarn coveralls
23+
# env:
24+
# COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
25+
# COVERALLS_GIT_BRANCH: ${{ github.ref }}

Diff for: .github/workflows/docs.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Docs
2+
3+
on:
4+
push:
5+
branches: [develop]
6+
paths:
7+
- 'docs/**'
8+
- package.json
9+
- README.md
10+
11+
jobs:
12+
build-docs:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
with:
18+
persist-credentials: false
19+
- name: Setup Node JS
20+
uses: actions/setup-node@v1
21+
with:
22+
node-version: 12.x
23+
- name: Build Docs 📚
24+
run: |
25+
# un-ignore bundle.js
26+
mv docs/.gitignore .gitignore
27+
yarn install --ignore-engines
28+
yarn build:docs
29+
- name: Deploy Pages 🚀
30+
uses: JamesIves/github-pages-deploy-action@releases/v3
31+
with:
32+
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
33+
BRANCH: gh-pages
34+
FOLDER: docs

Diff for: .github/workflows/release.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [master]
6+
7+
jobs:
8+
build-release:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Setup Node JS
14+
uses: actions/setup-node@v1
15+
with:
16+
node-version: 12.x
17+
- run: yarn install --ignore-engines
18+
- run: yarn lint:nofix
19+
- run: yarn test
20+
- name: Release to npm 🚀
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
24+
run: |
25+
yarn add semantic-release
26+
yarn semantic-release

Diff for: .travis.yml

-28
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,7 @@ jobs:
1212
install:
1313
- yarn install --ignore-engines
1414
script:
15-
- yarn lint:nofix
1615
- yarn coveralls
1716
branches:
1817
except:
1918
- /^v\d+\.\d+\.\d+$/
20-
# Define the release stage that runs semantic-release
21-
- stage: release
22-
if: (NOT type IN (pull_request)) AND (branch = master)
23-
node_js: '10'
24-
# overwrite default `script` step to skip the tests
25-
script: echo "Deploying to npm ..."
26-
deploy:
27-
provider: script
28-
skip_cleanup: true
29-
script:
30-
- npx semantic-release
31-
- stage: docs
32-
if: (NOT type IN (pull_request)) AND (branch = develop)
33-
node_js: '10'
34-
# un-ignore bundle.js
35-
before_deploy: mv docs/.gitignore .gitignore
36-
# overwrite default `script` step to skip the tests
37-
script: yarn build:docs
38-
deploy:
39-
provider: pages
40-
skip-cleanup: true
41-
github-token: $GH_PAGES_TOKEN # Set in the settings page of the repository, as a secure variable
42-
keep-history: true
43-
local-dir: docs
44-
verbose: true
45-
on:
46-
branch: develop

Diff for: README.md

+49-6
Large diffs are not rendered by default.

Diff for: src/index.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,16 @@ class DropdownTreeSelect extends Component {
7575
rootPrefixId: this.clientId,
7676
searchPredicate,
7777
})
78-
// Restore focus-state
79-
const currentFocusNode = this.state.currentFocus && this.treeManager.getNodeById(this.state.currentFocus)
80-
if (currentFocusNode) {
81-
currentFocusNode._focused = true
82-
}
83-
this.setState(prevState => ({
84-
showDropdown: /initial|always/.test(showDropdown) || prevState.showDropdown === true,
85-
...this.treeManager.getTreeAndTags(),
86-
}))
78+
this.setState(prevState => {
79+
const currentFocusNode = prevState.currentFocus && this.treeManager.getNodeById(prevState.currentFocus)
80+
if (currentFocusNode) {
81+
currentFocusNode._focused = true
82+
}
83+
return {
84+
showDropdown: /initial|always/.test(showDropdown) || prevState.showDropdown === true,
85+
...this.treeManager.getTreeAndTags(),
86+
}
87+
})
8788
}
8889

8990
resetSearchState = () => {

Diff for: src/index.test.js

+41
Original file line numberDiff line numberDiff line change
@@ -316,3 +316,44 @@ test('appends selected tags to aria-labelledby with text label', t => {
316316
t.deepEqual(wrapper.find('.dropdown-trigger').prop('aria-labelledby'), 'rdts_trigger rdts-0_tag')
317317
t.deepEqual(wrapper.find('.dropdown-trigger').prop('aria-label'), 'hello world')
318318
})
319+
320+
test('select correct focused node when using external state data container', t => {
321+
let data = [
322+
{
323+
label: 'All data',
324+
value: '0',
325+
checked: false,
326+
},
327+
{
328+
label: 'iWay',
329+
value: '1',
330+
checked: false,
331+
},
332+
]
333+
const wrapper = mount(<DropdownTreeSelect id={dropdownId} data={data} />)
334+
const nodeAllData = {
335+
_id: `${dropdownId}-0`,
336+
_depth: 0,
337+
label: 'All data',
338+
value: '0',
339+
children: undefined,
340+
actions: [action],
341+
}
342+
wrapper.instance().onCheckboxChange(nodeAllData._id, true)
343+
//simulate external change to the data props.
344+
wrapper.setProps({
345+
data: [
346+
{
347+
label: 'All data',
348+
value: '0',
349+
checked: true,
350+
},
351+
{
352+
label: 'iWay',
353+
value: '1',
354+
checked: false,
355+
},
356+
],
357+
})
358+
t.deepEqual(wrapper.state().currentFocus, nodeAllData._id)
359+
})

0 commit comments

Comments
 (0)