Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const config = {
'algolia/react',
'algolia/typescript',
'plugin:react-hooks/recommended',
'plugin:de-morgan/recommended-legacy',
],
plugins: ['react-hooks', 'deprecation'],
globals: {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"@babel/preset-typescript": "7.26.0",
"@googlemaps/jest-mocks": "2.7.5",
"@microsoft/api-extractor": "7.45.1",
"@rollup/plugin-terser": "0.4.4",
"@storybook/addon-actions": "5.3.9",
"@storybook/addon-knobs": "5.3.9",
"@storybook/addon-options": "5.3.9",
Expand Down Expand Up @@ -104,6 +105,7 @@
"eslint-config-prettier": "6.15.0",
"eslint-import-resolver-typescript": "2.5.0",
"eslint-plugin-compat": "6.0.1",
"eslint-plugin-de-morgan": "1.2.0",
"eslint-plugin-deprecation": "1.3.2",
"eslint-plugin-eslint-comments": "3.2.0",
"eslint-plugin-import": "2.24.2",
Expand Down Expand Up @@ -137,7 +139,6 @@
"rollup-plugin-node-globals": "1.4.0",
"rollup-plugin-node-resolve": "5.2.0",
"rollup-plugin-replace": "2.2.0",
"@rollup/plugin-terser": "0.4.4",
"shelljs": "0.8.5",
"shipjs": "0.26.0",
"ts-jest": "27",
Expand Down
2 changes: 1 addition & 1 deletion packages/algoliasearch-helper/src/SearchResults/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ SearchResults.prototype.getFacetValues = function (attribute, opts) {
sortBy: SearchResults.DEFAULT_SORT,
// if no sortBy is given, attempt to sort based on facetOrdering
// if it is given, we still allow to sort via facet ordering first
facetOrdering: !(opts && opts.sortBy),
facetOrdering: !opts || !opts.sortBy,
});

// eslint-disable-next-line consistent-this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,9 @@ export const connectDynamicWidgets: DynamicWidgetsConnector =
} = widgetParams;

if (
!(
widgets &&
Array.isArray(widgets) &&
widgets.every((widget) => typeof widget === 'object')
)
!widgets ||
!Array.isArray(widgets) ||
!widgets.every((widget) => typeof widget === 'object')
) {
throw new Error(
withUsage('The `widgets` option expects an array of widgets.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ export const connectInfiniteHits = function connectInfiniteHits<
cachedItems[page] === undefined &&
!results.__isArtificial &&
instantSearchInstance.status === 'idle' &&
!(hasDynamicWidgets && hasNoFacets)
(!hasDynamicWidgets || !hasNoFacets)
) {
cachedItems[page] = transformedHits;
cache.write({ state: normalizeState(state), items: cachedItems });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ export const connectNumericMenu: NumericMenuConnector =
return {
createURL: connectorState.createURL(state),
items: transformItems(preparedItems, { results }),
canRefine: !(hasNoResults && allIsSelected),
canRefine: !hasNoResults || !allIsSelected,
refine: connectorState.refine,
sendEvent: connectorState.sendEvent,
widgetParams,
Expand Down
6 changes: 3 additions & 3 deletions packages/instantsearch-core/src/routing/historyRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ export function historyRouter<TRouteState = UiState>({
// OR
// - the last write was from InstantSearch.js
// (unlike a SPA, where it would have last written)
const lastPushWasByISAfterDispose = !(
router.isDisposed && latestAcknowledgedHistory !== window.history.length
);
const lastPushWasByISAfterDispose =
!router.isDisposed ||
latestAcknowledgedHistory === window.history.length;

return (
// When the last state change was through popstate, the IS.js state changes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ class RefinementList<TTemplates extends Templates> extends Component<
public render() {
const showMoreButtonClassName = cx(
this.props.cssClasses.showMore,
!(this.props.showMore === true && this.props.canToggleShowMore) &&
(this.props.showMore !== true || !this.props.canToggleShowMore) &&
this.props.cssClasses.disabledShowMore
);

Expand All @@ -321,7 +321,8 @@ class RefinementList<TTemplates extends Templates> extends Component<

const shouldDisableSearchBox =
this.props.searchIsAlwaysActive !== true &&
!(this.props.isFromSearch || !this.props.hasExhaustiveItems);
!this.props.isFromSearch &&
this.props.hasExhaustiveItems;

const searchBox = this.props.searchFacetValues && (
<div className={this.props.cssClasses.searchBox}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,8 @@ class SearchBox extends Component<
const query = (event.target as HTMLInputElement).value;

if (
!(
this.props.ignoreCompositionEvents &&
(event as KeyboardEvent).isComposing
)
!this.props.ignoreCompositionEvents ||
!(event as KeyboardEvent).isComposing
) {
if (searchAsYouType) {
refine(query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@ const dynamicWidgets: DynamicWidgetsWidget = function dynamicWidgets(
}

if (
!(
widgets &&
Array.isArray(widgets) &&
widgets.every((widget) => typeof widget === 'function')
)
!widgets ||
!Array.isArray(widgets) ||
!widgets.every((widget) => typeof widget === 'function')
) {
throw new Error(
withUsage('The `widgets` option expects an array of callbacks.')
Expand Down
2 changes: 1 addition & 1 deletion packages/instantsearch.js/src/widgets/panel/panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ const panel: PanelWidget = (panelWidgetParams) => {
};

return (widgetFactory) => (widgetParams) => {
if (!(widgetParams && widgetParams.container)) {
if (!widgetParams || !widgetParams.container) {
throw new Error(
withUsage(
`The \`container\` option is required in the widget within the panel.`
Expand Down
2 changes: 1 addition & 1 deletion packages/react-instantsearch/src/widgets/SearchBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function SearchBox({
function setQuery(newQuery: string, isComposing = false) {
setInputValue(newQuery);

if (searchAsYouType && !(ignoreCompositionEvents && isComposing)) {
if (searchAsYouType && (!ignoreCompositionEvents || !isComposing)) {
refine(newQuery);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-instantsearch/src/components/SearchInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export default {
return document.activeElement === this.$refs.input;
},
onInput(event) {
if (!(this.ignoreCompositionEvents && event.isComposing)) {
if (!this.ignoreCompositionEvents || !event.isComposing) {
this.$emit('input', event.target.value);
this.$emit('update:modelValue', event.target.value);
}
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14049,6 +14049,11 @@ [email protected]:
lodash.memoize "^4.1.2"
semver "^7.6.2"

[email protected]:
version "1.2.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-de-morgan/-/eslint-plugin-de-morgan-1.2.0.tgz#bf3aaa68e82835beee6010179fbf7019bca9ff1d"
integrity sha512-XOZxiOMHchXn425a1DS/NOXVkGqKiTOCvVGIPru/l/bfF4Ant7u8d4+rXOqVFEN5Z8K+I/AO19U074gqnnBsJw==

[email protected]:
version "1.3.2"
resolved "https://registry.yarnpkg.com/eslint-plugin-deprecation/-/eslint-plugin-deprecation-1.3.2.tgz#a8125d28c56158cdfa1a685197e6be8ed86f189e"
Expand Down