instantsearch.js 4.75.1 → 4.75.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -50,7 +50,9 @@ var RefinementList = /*#__PURE__*/function (_Component) {
50
50
  args[_key] = arguments[_key];
51
51
  }
52
52
  _this = _super.call.apply(_super, [this].concat(args));
53
+ _defineProperty(_assertThisInitialized(_this), "listRef", (0, _preact.createRef)());
53
54
  _defineProperty(_assertThisInitialized(_this), "searchBox", (0, _preact.createRef)());
55
+ _defineProperty(_assertThisInitialized(_this), "lastRefinedValue", undefined);
54
56
  _defineProperty(_assertThisInitialized(_this), "_generateFacetItem", function (facetValue) {
55
57
  var subItems;
56
58
  if (isHierarchicalMenuItem(facetValue) && Array.isArray(facetValue.data) && facetValue.data.length > 0) {
@@ -153,6 +155,7 @@ var RefinementList = /*#__PURE__*/function (_Component) {
153
155
  }, {
154
156
  key: "refine",
155
157
  value: function refine(facetValueToRefine) {
158
+ this.lastRefinedValue = facetValueToRefine;
156
159
  this.props.toggleRefinement(facetValueToRefine);
157
160
  }
158
161
  }, {
@@ -162,6 +165,19 @@ var RefinementList = /*#__PURE__*/function (_Component) {
162
165
  this.searchBox.current.resetInput();
163
166
  }
164
167
  }
168
+
169
+ /**
170
+ * This sets focus on the last refined input element after a render
171
+ * because Preact does not perform it automatically.
172
+ * @see https://github.com/preactjs/preact/issues/3242
173
+ */
174
+ }, {
175
+ key: "componentDidUpdate",
176
+ value: function componentDidUpdate() {
177
+ var _this$listRef$current, _this$listRef$current2;
178
+ (_this$listRef$current = this.listRef.current) === null || _this$listRef$current === void 0 ? void 0 : (_this$listRef$current2 = _this$listRef$current.querySelector("input[value=\"".concat(this.lastRefinedValue, "\"]"))) === null || _this$listRef$current2 === void 0 ? void 0 : _this$listRef$current2.focus();
179
+ this.lastRefinedValue = undefined;
180
+ }
165
181
  }, {
166
182
  key: "refineFirstValue",
167
183
  value: function refineFirstValue() {
@@ -213,6 +229,7 @@ var RefinementList = /*#__PURE__*/function (_Component) {
213
229
  ariaLabel: "Search for filters"
214
230
  }));
215
231
  var facetValues = this.props.facetValues && this.props.facetValues.length > 0 && (0, _preact.h)("ul", {
232
+ ref: this.listRef,
216
233
  className: this.props.cssClasses.list
217
234
  }, this.props.facetValues.map(this._generateFacetItem, this));
218
235
  var noResults = this.props.searchFacetValues && this.props.isFromSearch && (!this.props.facetValues || this.props.facetValues.length === 0) && (0, _preact.h)(_Template.default, _extends({}, this.props.templateProps, {
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _default = '4.75.1';
7
+ var _default = '4.75.2';
8
8
  exports.default = _default;
@@ -1,4 +1,4 @@
1
- /*! InstantSearch.js 4.75.1 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
1
+ /*! InstantSearch.js 4.75.2 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -16017,7 +16017,7 @@
16017
16017
  };
16018
16018
  }
16019
16019
 
16020
- var version$1 = '4.75.1';
16020
+ var version$1 = '4.75.2';
16021
16021
 
16022
16022
  var withUsage$v = createDocumentationMessageGenerator({
16023
16023
  name: 'instantsearch'
@@ -20246,7 +20246,9 @@
20246
20246
  args[_key] = arguments[_key];
20247
20247
  }
20248
20248
  _this = _super.call.apply(_super, [this].concat(args));
20249
+ _defineProperty(_assertThisInitialized(_this), "listRef", y());
20249
20250
  _defineProperty(_assertThisInitialized(_this), "searchBox", y());
20251
+ _defineProperty(_assertThisInitialized(_this), "lastRefinedValue", undefined);
20250
20252
  _defineProperty(_assertThisInitialized(_this), "_generateFacetItem", function (facetValue) {
20251
20253
  var subItems;
20252
20254
  if (isHierarchicalMenuItem(facetValue) && Array.isArray(facetValue.data) && facetValue.data.length > 0) {
@@ -20349,6 +20351,7 @@
20349
20351
  }, {
20350
20352
  key: "refine",
20351
20353
  value: function refine(facetValueToRefine) {
20354
+ this.lastRefinedValue = facetValueToRefine;
20352
20355
  this.props.toggleRefinement(facetValueToRefine);
20353
20356
  }
20354
20357
  }, {
@@ -20358,6 +20361,19 @@
20358
20361
  this.searchBox.current.resetInput();
20359
20362
  }
20360
20363
  }
20364
+
20365
+ /**
20366
+ * This sets focus on the last refined input element after a render
20367
+ * because Preact does not perform it automatically.
20368
+ * @see https://github.com/preactjs/preact/issues/3242
20369
+ */
20370
+ }, {
20371
+ key: "componentDidUpdate",
20372
+ value: function componentDidUpdate() {
20373
+ var _this$listRef$current, _this$listRef$current2;
20374
+ (_this$listRef$current = this.listRef.current) === null || _this$listRef$current === void 0 ? void 0 : (_this$listRef$current2 = _this$listRef$current.querySelector("input[value=\"".concat(this.lastRefinedValue, "\"]"))) === null || _this$listRef$current2 === void 0 ? void 0 : _this$listRef$current2.focus();
20375
+ this.lastRefinedValue = undefined;
20376
+ }
20361
20377
  }, {
20362
20378
  key: "refineFirstValue",
20363
20379
  value: function refineFirstValue() {
@@ -20409,6 +20425,7 @@
20409
20425
  ariaLabel: "Search for filters"
20410
20426
  }));
20411
20427
  var facetValues = this.props.facetValues && this.props.facetValues.length > 0 && h("ul", {
20428
+ ref: this.listRef,
20412
20429
  className: this.props.cssClasses.list
20413
20430
  }, this.props.facetValues.map(this._generateFacetItem, this));
20414
20431
  var noResults = this.props.searchFacetValues && this.props.isFromSearch && (!this.props.facetValues || this.props.facetValues.length === 0) && h(Template, _extends({}, this.props.templateProps, {