Skip to content

Commit

Permalink
Merge pull request #2265 from appbaseio/fix/search-tag-mode
Browse files Browse the repository at this point in the history
fix(web/searchbox): clearing input shouldn't clear selected tags
  • Loading branch information
siddharthlatest authored Nov 2, 2023
2 parents c1f9f52 + cc98759 commit 7bc4904
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 116 deletions.
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

2 changes: 1 addition & 1 deletion packages/maps-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"react-native": "~0.62.3"
},
"dependencies": {
"@appbaseio/reactivecore": "10.2.0",
"@appbaseio/reactivecore": "10.2.1",
"@ptomasroos/react-native-multi-slider": "^0.0.13",
"appbase-js": "^5.2.0",
"hoist-non-react-statics": "^3.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"react-native": "~0.62.3"
},
"dependencies": {
"@appbaseio/reactivecore": "10.2.0",
"@appbaseio/reactivecore": "10.2.1",
"@babel/polyfill": "^7.0.0-rc.3",
"@ptomasroos/react-native-multi-slider": "^1.0.0",
"appbase-js": "^5.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/reactivecore
4 changes: 2 additions & 2 deletions packages/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"sideEffects": false,
"dependencies": {
"@appbaseio/analytics": "^1.2.0-alpha.1",
"@appbaseio/reactivecore": "10.2.0",
"@appbaseio/reactivecore": "10.2.1",
"@appbaseio/vue-emotion": "0.6.0-alpha.6",
"@emotion/css": "^11.10.5",
"@vue/babel-helper-vue-jsx-merge-props": "^1.0.0",
Expand Down Expand Up @@ -90,4 +90,4 @@
"typescript": "^5.0.0",
"vue-eslint-parser": "^3.2.2"
}
}
}
192 changes: 96 additions & 96 deletions packages/web/package.json
Original file line number Diff line number Diff line change
@@ -1,97 +1,97 @@
{
"name": "@appbaseio/reactivesearch",
"version": "4.2.0",
"description": "A React UI components library for building search experirnences",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"module": "lib/index.es.js",
"js:next": "lib/index.es.js",
"sideEffects": false,
"files": [
"lib/",
"umd"
],
"scripts": {
"watch": "yarn build:commonjs -w && yarn build:es -w",
"build": "yarn build:commonjs && yarn build:es && yarn build:copy-types",
"build:commonjs": "cross-env BABEL_ENV=commonjs babel --ignore __tests__ src --out-dir lib",
"build:es": "cross-env BABEL_ENV=es babel src/index.js --out-file lib/index.es.js",
"build:copy-types": "npx babel-node ./scripts/copy-types.js",
"build:umd": "cross-env BABEL_ENV=commonjs webpack --progress -p --config webpack.config.umd.js",
"stats": "webpack --progress -p --config webpack.config.umd.js --json > stats.json",
"version-upgrade": "nps upgrade -c ../../package-scripts.js",
"prepublishOnly": "yarn run build",
"postpublish": "yarn run version-upgrade",
"test": "jest",
"clear-cache-test": "jest --clearCache",
"typescript": "tsc -p tsconfig.json"
},
"jest": {
"rootDir": "src",
"testURL": "http://localhost/"
},
"repository": {
"type": "git",
"url": "https://github.com/appbaseio/reactivesearch.git"
},
"author": "metagrover",
"license": "Apache-2.0",
"dependencies": {
"@appbaseio/analytics": "^1.2.0-alpha.1",
"@appbaseio/reactivecore": "10.2.0",
"@appbaseio/rheostat": "^1.0.0-alpha.15",
"@emotion/core": "^10.0.28",
"@emotion/styled": "^10.0.27",
"appbase-js": "^5.3.3",
"cross-env": "^5.2.0",
"dayjs": "^1.11.7",
"downshift": "^1.31.2",
"echarts": "^5.3.3",
"echarts-for-react": "^3.0.2",
"emotion-theming": "^10.0.27",
"hoist-non-react-statics": "^3.2.1",
"hotkeys-js": "^3.8.7",
"polished": "^1.9.3",
"prop-types": "^15.6.0",
"react-day-picker": "^7.0.5",
"react-redux": "^6.0.1",
"remarkable": "^2.0.1",
"url-search-params-polyfill": "^7.0.0",
"xss": "^1.0.11"
},
"peerDependencies": {
"react": ">=15",
"react-dom": ">=15"
},
"devDependencies": {
"@emotion/jest": "11.7.1",
"@types/react": "^16.3.8",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-jest": "^22.4.4",
"babel-loader": "^7.1.2",
"babel-plugin-emotion": "^10.0.33",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"babili-webpack-plugin": "^0.1.2",
"brotli-webpack-plugin": "^0.5.0",
"compression-webpack-plugin": "^1.0.1",
"eslint-plugin-jest": "^21.12.2",
"fs-extra": "^7.0.0",
"glob": "^7.1.2",
"jest": "^22.4.2",
"nps": "^5.9.5",
"path": "^0.12.7",
"react": "^18.0.2",
"react-dom": "^18.0.2",
"react-test-renderer": "^18.2.0",
"tslint": "^5.9.1",
"typescript": "^2.8.1",
"webpack": "^4.18.0"
},
"resolutions": {
"@types/react": "16.3.7"
}
}
"name": "@appbaseio/reactivesearch",
"version": "4.2.0",
"description": "A React UI components library for building search experirnences",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"module": "lib/index.es.js",
"js:next": "lib/index.es.js",
"sideEffects": false,
"files": [
"lib/",
"umd"
],
"scripts": {
"watch": "yarn build:commonjs -w && yarn build:es -w",
"build": "yarn build:commonjs && yarn build:es && yarn build:copy-types",
"build:commonjs": "cross-env BABEL_ENV=commonjs babel --ignore __tests__ src --out-dir lib",
"build:es": "cross-env BABEL_ENV=es babel src/index.js --out-file lib/index.es.js",
"build:copy-types": "npx babel-node ./scripts/copy-types.js",
"build:umd": "cross-env BABEL_ENV=commonjs webpack --progress -p --config webpack.config.umd.js",
"stats": "webpack --progress -p --config webpack.config.umd.js --json > stats.json",
"version-upgrade": "nps upgrade -c ../../package-scripts.js",
"prepublishOnly": "yarn run build",
"postpublish": "yarn run version-upgrade",
"test": "jest",
"clear-cache-test": "jest --clearCache",
"typescript": "tsc -p tsconfig.json"
},
"jest": {
"rootDir": "src",
"testURL": "http://localhost/"
},
"repository": {
"type": "git",
"url": "https://github.com/appbaseio/reactivesearch.git"
},
"author": "metagrover",
"license": "Apache-2.0",
"dependencies": {
"@appbaseio/analytics": "^1.2.0-alpha.1",
"@appbaseio/reactivecore": "10.2.1",
"@appbaseio/rheostat": "^1.0.0-alpha.15",
"@emotion/core": "^10.0.28",
"@emotion/styled": "^10.0.27",
"appbase-js": "^5.3.3",
"cross-env": "^5.2.0",
"dayjs": "^1.11.7",
"downshift": "^1.31.2",
"echarts": "^5.3.3",
"echarts-for-react": "^3.0.2",
"emotion-theming": "^10.0.27",
"hoist-non-react-statics": "^3.2.1",
"hotkeys-js": "^3.8.7",
"polished": "^1.9.3",
"prop-types": "^15.6.0",
"react-day-picker": "^7.0.5",
"react-redux": "^6.0.1",
"remarkable": "^2.0.1",
"url-search-params-polyfill": "^7.0.0",
"xss": "^1.0.11"
},
"peerDependencies": {
"react": ">=15",
"react-dom": ">=15"
},
"devDependencies": {
"@emotion/jest": "11.7.1",
"@types/react": "^16.3.8",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-jest": "^22.4.4",
"babel-loader": "^7.1.2",
"babel-plugin-emotion": "^10.0.33",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"babili-webpack-plugin": "^0.1.2",
"brotli-webpack-plugin": "^0.5.0",
"compression-webpack-plugin": "^1.0.1",
"eslint-plugin-jest": "^21.12.2",
"fs-extra": "^7.0.0",
"glob": "^7.1.2",
"jest": "^22.4.2",
"nps": "^5.9.5",
"path": "^0.12.7",
"react": "^18.0.2",
"react-dom": "^18.0.2",
"react-test-renderer": "^18.2.0",
"tslint": "^5.9.1",
"typescript": "^2.8.1",
"webpack": "^4.18.0"
},
"resolutions": {
"@types/react": "16.3.7"
}
}
10 changes: 7 additions & 3 deletions packages/web/src/components/search/SearchBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,9 @@ const SearchBox = (props) => {
return;
}
let newSelectedTags = [];
if (cause !== causes.CLEAR_ALL_TAGS) {
newSelectedTags = selectedTags;
}
let newCurrentValue = decodeHtml(value);
if (hasMounted) {
if (isTagsMode.current && cause === causes.SUGGESTION_SELECT) {
Expand All @@ -457,9 +460,9 @@ const SearchBox = (props) => {
}

if (typeof value === 'string' && !!value) {
newSelectedTags = [...selectedTags, value];
newSelectedTags = [...newSelectedTags, value];
} else if (Array.isArray(value) && !isEqual(selectedTags, value)) {
const mergedArray = Array.from(new Set([...selectedTags, ...value]));
const mergedArray = Array.from(new Set([...newSelectedTags, ...value]));
newSelectedTags = mergedArray;
}
} else if (value) {
Expand Down Expand Up @@ -744,6 +747,7 @@ const SearchBox = (props) => {
if (showAIScreen) {
setShowAIScreen(false);
}
// for !controlled usage, we need to update the value directly
if (value === undefined) {
setValue(inputValue, inputValue === '', props, undefined, true, false);
} else if (onChange) {
Expand Down Expand Up @@ -1328,7 +1332,7 @@ const SearchBox = (props) => {
const clearAllTags = () => {
setSelectedTags([]);

setValue('', true, props, causes.SUGGESTION_SELECT, hasMounted.current, false);
setValue('', true, props, causes.CLEAR_ALL_TAGS, hasMounted.current, false);
if (props.value !== undefined && typeof onChange === 'function') {
onChange([], ({ isOpen } = {}) =>
triggerQuery({
Expand Down
11 changes: 0 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -181,17 +181,6 @@
tocbot "^4.18.0"
yarn "^1.22.18"

"@appbaseio/[email protected]":
version "10.2.0"
resolved "https://registry.yarnpkg.com/@appbaseio/reactivecore/-/reactivecore-10.2.0.tgz#44d3ad3f5f40062e24fdfadb877ab7dc2efcd4a3"
integrity sha512-unx9e8HLw/y7SO/1nL9ehpo95SsWsp4umoDvIraRxXJ3sfRYl+5dB91b2U9DG8D1XqBgbf18JTsfktu9yFQjDg==
dependencies:
cross-fetch "^3.0.4"
dayjs "^1.11.7"
prop-types "^15.6.0"
redux "^4.0.0"
redux-thunk "^2.3.0"

"@appbaseio/[email protected]":
version "9.15.1"
resolved "https://registry.yarnpkg.com/@appbaseio/reactivecore/-/reactivecore-9.15.1.tgz#283dff65f5cb15db58a48702b8238bdf38940850"
Expand Down

0 comments on commit 7bc4904

Please sign in to comment.