From 6362300c7afc582b367a78cff4f07cb2ad7cae33 Mon Sep 17 00:00:00 2001 From: Siddharth Kothari Date: Wed, 1 Nov 2023 10:56:07 +0700 Subject: [PATCH 1/2] fix(web/searchbox): clearing input shouldn't clear selected tags --- packages/maps-native/package.json | 2 +- packages/native/package.json | 2 +- packages/reactivecore | 2 +- packages/vue/package.json | 4 +- packages/web/package.json | 192 +++++++++--------- .../web/src/components/search/SearchBox.js | 10 +- yarn.lock | 11 - 7 files changed, 108 insertions(+), 115 deletions(-) diff --git a/packages/maps-native/package.json b/packages/maps-native/package.json index 1e31ff4a9..58040a24b 100644 --- a/packages/maps-native/package.json +++ b/packages/maps-native/package.json @@ -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", diff --git a/packages/native/package.json b/packages/native/package.json index 00db6af08..93b1c29ff 100644 --- a/packages/native/package.json +++ b/packages/native/package.json @@ -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", diff --git a/packages/reactivecore b/packages/reactivecore index 5f9364433..903e41ced 160000 --- a/packages/reactivecore +++ b/packages/reactivecore @@ -1 +1 @@ -Subproject commit 5f93644336edced91ebe64f2ee38672aa093a546 +Subproject commit 903e41ced26578cb4b9a4c73aadd58afb2e63550 diff --git a/packages/vue/package.json b/packages/vue/package.json index 8203177fa..ebf738409 100644 --- a/packages/vue/package.json +++ b/packages/vue/package.json @@ -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", @@ -90,4 +90,4 @@ "typescript": "^5.0.0", "vue-eslint-parser": "^3.2.2" } -} +} \ No newline at end of file diff --git a/packages/web/package.json b/packages/web/package.json index 1b5fad39f..ba426b264 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -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" + } +} \ No newline at end of file diff --git a/packages/web/src/components/search/SearchBox.js b/packages/web/src/components/search/SearchBox.js index db32e146d..5a466d045 100644 --- a/packages/web/src/components/search/SearchBox.js +++ b/packages/web/src/components/search/SearchBox.js @@ -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) { @@ -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) { @@ -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) { @@ -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({ diff --git a/yarn.lock b/yarn.lock index aa855f364..0338ec4ba 100644 --- a/yarn.lock +++ b/yarn.lock @@ -181,17 +181,6 @@ tocbot "^4.18.0" yarn "^1.22.18" -"@appbaseio/reactivecore@10.2.0": - 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/reactivecore@9.15.1": version "9.15.1" resolved "https://registry.yarnpkg.com/@appbaseio/reactivecore/-/reactivecore-9.15.1.tgz#283dff65f5cb15db58a48702b8238bdf38940850" From cc9875961786fc26ad9c2f434d2fdb98be385109 Mon Sep 17 00:00:00 2001 From: Siddharth Kothari Date: Wed, 1 Nov 2023 10:59:31 +0700 Subject: [PATCH 2/2] chore: remove requirement of node 14.17.1 --- .nvmrc | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .nvmrc diff --git a/.nvmrc b/.nvmrc deleted file mode 100644 index 2ccd0b76b..000000000 --- a/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -v14.17.1