@salesforcedevs/dx-components 0.19.3-alpha → 0.19.3-alpha.10

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dx-components",
3
- "version": "0.19.3-alpha",
3
+ "version": "0.19.3-alpha.10",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -27,6 +27,7 @@ export const SESSION_KEY = "dx-sidebar-search-state";
27
27
 
28
28
  const DEFAULT_RESULT_COUNT = 20;
29
29
  const SEARCH_DEBOUNCE_DELAY = 780;
30
+ const HIGHLIGHT_DEBOUNCE_DELAY = 200;
30
31
 
31
32
  const UserRecentSearches = new RecentSearches();
32
33
 
@@ -217,10 +218,6 @@ export default class SidebarSearch extends LightningElement {
217
218
  this.onResultListChange
218
219
  );
219
220
 
220
- if (this.value) {
221
- this.dispatchHighlightedTermChange();
222
- }
223
-
224
221
  if (!this.preloadedState) {
225
222
  if (this.value) {
226
223
  this.submitSearch();
@@ -337,7 +334,7 @@ export default class SidebarSearch extends LightningElement {
337
334
  this.dispatchEvent(new CustomEvent("loading", { detail: loading }));
338
335
  }
339
336
 
340
- private dispatchHighlightedTermChange() {
337
+ private dispatchHighlightedTermChange = debounce(() => {
341
338
  this.dispatchEvent(
342
339
  new CustomEvent("highlightedtermchange", {
343
340
  detail: this.value,
@@ -345,7 +342,7 @@ export default class SidebarSearch extends LightningElement {
345
342
  bubbles: true
346
343
  })
347
344
  );
348
- }
345
+ }, HIGHLIGHT_DEBOUNCE_DELAY);
349
346
 
350
347
  private updateRecentSearches = () =>
351
348
  (this.recentSearches = UserRecentSearches.get().map((item: string) => ({
@@ -9,6 +9,7 @@ export const highlightTerms = (
9
9
  ): void => {
10
10
  searchTerm = searchTerm.trim();
11
11
  const searchExp = createSearchRegExp(searchTerm);
12
+ let scrolled = false;
12
13
  elements.forEach((element) => {
13
14
  if (
14
15
  element?.innerHTML.includes("<dx-") ||
@@ -27,10 +28,13 @@ export const highlightTerms = (
27
28
  innerHtml = innerHtml.replace(searchExp, "<mark>$&</mark>");
28
29
  }
29
30
 
31
+ const mark = element.querySelector("mark");
32
+
33
+ if (mark && !scrolled) {
34
+ scrolled = true;
35
+ element.scrollIntoView({ block: "nearest" });
36
+ }
37
+
30
38
  element.innerHTML = innerHtml;
31
39
  });
32
-
33
- if (elements.length > 0) {
34
- elements[0].scrollIntoView(true);
35
- }
36
40
  };