Skip to content

Commit 6362300

Browse files
fix(web/searchbox): clearing input shouldn't clear selected tags
1 parent c1f9f52 commit 6362300

File tree

7 files changed

+108
-115
lines changed

7 files changed

+108
-115
lines changed

packages/maps-native/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"react-native": "~0.62.3"
4848
},
4949
"dependencies": {
50-
"@appbaseio/reactivecore": "10.2.0",
50+
"@appbaseio/reactivecore": "10.2.1",
5151
"@ptomasroos/react-native-multi-slider": "^0.0.13",
5252
"appbase-js": "^5.2.0",
5353
"hoist-non-react-statics": "^3.3.0",

packages/native/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"react-native": "~0.62.3"
4545
},
4646
"dependencies": {
47-
"@appbaseio/reactivecore": "10.2.0",
47+
"@appbaseio/reactivecore": "10.2.1",
4848
"@babel/polyfill": "^7.0.0-rc.3",
4949
"@ptomasroos/react-native-multi-slider": "^1.0.0",
5050
"appbase-js": "^5.2.0",

packages/vue/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"sideEffects": false,
3636
"dependencies": {
3737
"@appbaseio/analytics": "^1.2.0-alpha.1",
38-
"@appbaseio/reactivecore": "10.2.0",
38+
"@appbaseio/reactivecore": "10.2.1",
3939
"@appbaseio/vue-emotion": "0.6.0-alpha.6",
4040
"@emotion/css": "^11.10.5",
4141
"@vue/babel-helper-vue-jsx-merge-props": "^1.0.0",
@@ -90,4 +90,4 @@
9090
"typescript": "^5.0.0",
9191
"vue-eslint-parser": "^3.2.2"
9292
}
93-
}
93+
}

packages/web/package.json

Lines changed: 96 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,97 @@
11
{
2-
"name": "@appbaseio/reactivesearch",
3-
"version": "4.2.0",
4-
"description": "A React UI components library for building search experirnences",
5-
"main": "lib/index.js",
6-
"types": "lib/index.d.ts",
7-
"module": "lib/index.es.js",
8-
"js:next": "lib/index.es.js",
9-
"sideEffects": false,
10-
"files": [
11-
"lib/",
12-
"umd"
13-
],
14-
"scripts": {
15-
"watch": "yarn build:commonjs -w && yarn build:es -w",
16-
"build": "yarn build:commonjs && yarn build:es && yarn build:copy-types",
17-
"build:commonjs": "cross-env BABEL_ENV=commonjs babel --ignore __tests__ src --out-dir lib",
18-
"build:es": "cross-env BABEL_ENV=es babel src/index.js --out-file lib/index.es.js",
19-
"build:copy-types": "npx babel-node ./scripts/copy-types.js",
20-
"build:umd": "cross-env BABEL_ENV=commonjs webpack --progress -p --config webpack.config.umd.js",
21-
"stats": "webpack --progress -p --config webpack.config.umd.js --json > stats.json",
22-
"version-upgrade": "nps upgrade -c ../../package-scripts.js",
23-
"prepublishOnly": "yarn run build",
24-
"postpublish": "yarn run version-upgrade",
25-
"test": "jest",
26-
"clear-cache-test": "jest --clearCache",
27-
"typescript": "tsc -p tsconfig.json"
28-
},
29-
"jest": {
30-
"rootDir": "src",
31-
"testURL": "http://localhost/"
32-
},
33-
"repository": {
34-
"type": "git",
35-
"url": "https://github.com/appbaseio/reactivesearch.git"
36-
},
37-
"author": "metagrover",
38-
"license": "Apache-2.0",
39-
"dependencies": {
40-
"@appbaseio/analytics": "^1.2.0-alpha.1",
41-
"@appbaseio/reactivecore": "10.2.0",
42-
"@appbaseio/rheostat": "^1.0.0-alpha.15",
43-
"@emotion/core": "^10.0.28",
44-
"@emotion/styled": "^10.0.27",
45-
"appbase-js": "^5.3.3",
46-
"cross-env": "^5.2.0",
47-
"dayjs": "^1.11.7",
48-
"downshift": "^1.31.2",
49-
"echarts": "^5.3.3",
50-
"echarts-for-react": "^3.0.2",
51-
"emotion-theming": "^10.0.27",
52-
"hoist-non-react-statics": "^3.2.1",
53-
"hotkeys-js": "^3.8.7",
54-
"polished": "^1.9.3",
55-
"prop-types": "^15.6.0",
56-
"react-day-picker": "^7.0.5",
57-
"react-redux": "^6.0.1",
58-
"remarkable": "^2.0.1",
59-
"url-search-params-polyfill": "^7.0.0",
60-
"xss": "^1.0.11"
61-
},
62-
"peerDependencies": {
63-
"react": ">=15",
64-
"react-dom": ">=15"
65-
},
66-
"devDependencies": {
67-
"@emotion/jest": "11.7.1",
68-
"@types/react": "^16.3.8",
69-
"babel-cli": "^6.26.0",
70-
"babel-core": "^6.26.0",
71-
"babel-jest": "^22.4.4",
72-
"babel-loader": "^7.1.2",
73-
"babel-plugin-emotion": "^10.0.33",
74-
"babel-plugin-transform-class-properties": "^6.24.1",
75-
"babel-plugin-transform-object-rest-spread": "^6.26.0",
76-
"babel-preset-env": "^1.6.1",
77-
"babel-preset-react": "^6.24.1",
78-
"babili-webpack-plugin": "^0.1.2",
79-
"brotli-webpack-plugin": "^0.5.0",
80-
"compression-webpack-plugin": "^1.0.1",
81-
"eslint-plugin-jest": "^21.12.2",
82-
"fs-extra": "^7.0.0",
83-
"glob": "^7.1.2",
84-
"jest": "^22.4.2",
85-
"nps": "^5.9.5",
86-
"path": "^0.12.7",
87-
"react": "^18.0.2",
88-
"react-dom": "^18.0.2",
89-
"react-test-renderer": "^18.2.0",
90-
"tslint": "^5.9.1",
91-
"typescript": "^2.8.1",
92-
"webpack": "^4.18.0"
93-
},
94-
"resolutions": {
95-
"@types/react": "16.3.7"
96-
}
97-
}
2+
"name": "@appbaseio/reactivesearch",
3+
"version": "4.2.0",
4+
"description": "A React UI components library for building search experirnences",
5+
"main": "lib/index.js",
6+
"types": "lib/index.d.ts",
7+
"module": "lib/index.es.js",
8+
"js:next": "lib/index.es.js",
9+
"sideEffects": false,
10+
"files": [
11+
"lib/",
12+
"umd"
13+
],
14+
"scripts": {
15+
"watch": "yarn build:commonjs -w && yarn build:es -w",
16+
"build": "yarn build:commonjs && yarn build:es && yarn build:copy-types",
17+
"build:commonjs": "cross-env BABEL_ENV=commonjs babel --ignore __tests__ src --out-dir lib",
18+
"build:es": "cross-env BABEL_ENV=es babel src/index.js --out-file lib/index.es.js",
19+
"build:copy-types": "npx babel-node ./scripts/copy-types.js",
20+
"build:umd": "cross-env BABEL_ENV=commonjs webpack --progress -p --config webpack.config.umd.js",
21+
"stats": "webpack --progress -p --config webpack.config.umd.js --json > stats.json",
22+
"version-upgrade": "nps upgrade -c ../../package-scripts.js",
23+
"prepublishOnly": "yarn run build",
24+
"postpublish": "yarn run version-upgrade",
25+
"test": "jest",
26+
"clear-cache-test": "jest --clearCache",
27+
"typescript": "tsc -p tsconfig.json"
28+
},
29+
"jest": {
30+
"rootDir": "src",
31+
"testURL": "http://localhost/"
32+
},
33+
"repository": {
34+
"type": "git",
35+
"url": "https://github.com/appbaseio/reactivesearch.git"
36+
},
37+
"author": "metagrover",
38+
"license": "Apache-2.0",
39+
"dependencies": {
40+
"@appbaseio/analytics": "^1.2.0-alpha.1",
41+
"@appbaseio/reactivecore": "10.2.1",
42+
"@appbaseio/rheostat": "^1.0.0-alpha.15",
43+
"@emotion/core": "^10.0.28",
44+
"@emotion/styled": "^10.0.27",
45+
"appbase-js": "^5.3.3",
46+
"cross-env": "^5.2.0",
47+
"dayjs": "^1.11.7",
48+
"downshift": "^1.31.2",
49+
"echarts": "^5.3.3",
50+
"echarts-for-react": "^3.0.2",
51+
"emotion-theming": "^10.0.27",
52+
"hoist-non-react-statics": "^3.2.1",
53+
"hotkeys-js": "^3.8.7",
54+
"polished": "^1.9.3",
55+
"prop-types": "^15.6.0",
56+
"react-day-picker": "^7.0.5",
57+
"react-redux": "^6.0.1",
58+
"remarkable": "^2.0.1",
59+
"url-search-params-polyfill": "^7.0.0",
60+
"xss": "^1.0.11"
61+
},
62+
"peerDependencies": {
63+
"react": ">=15",
64+
"react-dom": ">=15"
65+
},
66+
"devDependencies": {
67+
"@emotion/jest": "11.7.1",
68+
"@types/react": "^16.3.8",
69+
"babel-cli": "^6.26.0",
70+
"babel-core": "^6.26.0",
71+
"babel-jest": "^22.4.4",
72+
"babel-loader": "^7.1.2",
73+
"babel-plugin-emotion": "^10.0.33",
74+
"babel-plugin-transform-class-properties": "^6.24.1",
75+
"babel-plugin-transform-object-rest-spread": "^6.26.0",
76+
"babel-preset-env": "^1.6.1",
77+
"babel-preset-react": "^6.24.1",
78+
"babili-webpack-plugin": "^0.1.2",
79+
"brotli-webpack-plugin": "^0.5.0",
80+
"compression-webpack-plugin": "^1.0.1",
81+
"eslint-plugin-jest": "^21.12.2",
82+
"fs-extra": "^7.0.0",
83+
"glob": "^7.1.2",
84+
"jest": "^22.4.2",
85+
"nps": "^5.9.5",
86+
"path": "^0.12.7",
87+
"react": "^18.0.2",
88+
"react-dom": "^18.0.2",
89+
"react-test-renderer": "^18.2.0",
90+
"tslint": "^5.9.1",
91+
"typescript": "^2.8.1",
92+
"webpack": "^4.18.0"
93+
},
94+
"resolutions": {
95+
"@types/react": "16.3.7"
96+
}
97+
}

packages/web/src/components/search/SearchBox.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,9 @@ const SearchBox = (props) => {
446446
return;
447447
}
448448
let newSelectedTags = [];
449+
if (cause !== causes.CLEAR_ALL_TAGS) {
450+
newSelectedTags = selectedTags;
451+
}
449452
let newCurrentValue = decodeHtml(value);
450453
if (hasMounted) {
451454
if (isTagsMode.current && cause === causes.SUGGESTION_SELECT) {
@@ -457,9 +460,9 @@ const SearchBox = (props) => {
457460
}
458461

459462
if (typeof value === 'string' && !!value) {
460-
newSelectedTags = [...selectedTags, value];
463+
newSelectedTags = [...newSelectedTags, value];
461464
} else if (Array.isArray(value) && !isEqual(selectedTags, value)) {
462-
const mergedArray = Array.from(new Set([...selectedTags, ...value]));
465+
const mergedArray = Array.from(new Set([...newSelectedTags, ...value]));
463466
newSelectedTags = mergedArray;
464467
}
465468
} else if (value) {
@@ -744,6 +747,7 @@ const SearchBox = (props) => {
744747
if (showAIScreen) {
745748
setShowAIScreen(false);
746749
}
750+
// for !controlled usage, we need to update the value directly
747751
if (value === undefined) {
748752
setValue(inputValue, inputValue === '', props, undefined, true, false);
749753
} else if (onChange) {
@@ -1328,7 +1332,7 @@ const SearchBox = (props) => {
13281332
const clearAllTags = () => {
13291333
setSelectedTags([]);
13301334

1331-
setValue('', true, props, causes.SUGGESTION_SELECT, hasMounted.current, false);
1335+
setValue('', true, props, causes.CLEAR_ALL_TAGS, hasMounted.current, false);
13321336
if (props.value !== undefined && typeof onChange === 'function') {
13331337
onChange([], ({ isOpen } = {}) =>
13341338
triggerQuery({

yarn.lock

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -181,17 +181,6 @@
181181
tocbot "^4.18.0"
182182
yarn "^1.22.18"
183183

184-
"@appbaseio/[email protected]":
185-
version "10.2.0"
186-
resolved "https://registry.yarnpkg.com/@appbaseio/reactivecore/-/reactivecore-10.2.0.tgz#44d3ad3f5f40062e24fdfadb877ab7dc2efcd4a3"
187-
integrity sha512-unx9e8HLw/y7SO/1nL9ehpo95SsWsp4umoDvIraRxXJ3sfRYl+5dB91b2U9DG8D1XqBgbf18JTsfktu9yFQjDg==
188-
dependencies:
189-
cross-fetch "^3.0.4"
190-
dayjs "^1.11.7"
191-
prop-types "^15.6.0"
192-
redux "^4.0.0"
193-
redux-thunk "^2.3.0"
194-
195184
"@appbaseio/[email protected]":
196185
version "9.15.1"
197186
resolved "https://registry.yarnpkg.com/@appbaseio/reactivecore/-/reactivecore-9.15.1.tgz#283dff65f5cb15db58a48702b8238bdf38940850"

0 commit comments

Comments
 (0)