@salesforcedevs/dx-components 0.43.3-tree-selected-scroll-3 → 0.43.3-tree-selected-scroll-4

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.43.3-tree-selected-scroll-3",
3
+ "version": "0.43.3-tree-selected-scroll-4",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -4,9 +4,6 @@ export const HEIGHT_OF_SIDEBAR_ITEM = 32;
4
4
 
5
5
  export class SidebarBase extends LightningElement {
6
6
  _sidebarContent: HTMLElement | null = null;
7
- private selectedTreeItem: HTMLElement | null = null;
8
- private isSidebarRendered = false;
9
-
10
7
  get sidebarContent() {
11
8
  if (!this._sidebarContent) {
12
9
  this._sidebarContent = this.template.querySelector(
@@ -16,19 +13,13 @@ export class SidebarBase extends LightningElement {
16
13
  return this._sidebarContent;
17
14
  }
18
15
 
16
+ /*Scroll to selected tree item */
19
17
  private onSelectedItemRendered(event: CustomEvent) {
20
18
  event.stopPropagation();
21
- this.selectedTreeItem = event.detail.element;
22
- if (this.isSidebarRendered) {
23
- this.scrollToSelectedItem();
24
- }
25
- }
26
-
27
- /*Scroll to selected tree item */
28
- private scrollToSelectedItem(): void {
29
- if (this.selectedTreeItem && this.sidebarContent) {
19
+ const selectedTreeItem = event.detail.element;
20
+ if (selectedTreeItem && this.sidebarContent) {
30
21
  const scrollHeight: number =
31
- this.selectedTreeItem.getBoundingClientRect().bottom -
22
+ selectedTreeItem.getBoundingClientRect().bottom -
32
23
  this.sidebarContent.getBoundingClientRect().bottom + // We need to remove parent bottom
33
24
  HEIGHT_OF_SIDEBAR_ITEM * 3; // add height of 3 more items so that user can see at least three more items after selected item
34
25
  this.sidebarContent.scrollTo({
@@ -36,11 +27,5 @@ export class SidebarBase extends LightningElement {
36
27
  behavior: "smooth"
37
28
  });
38
29
  }
39
- this.selectedTreeItem = null;
40
- }
41
-
42
- renderedCallback(): void {
43
- this.isSidebarRendered = true;
44
- this.scrollToSelectedItem();
45
30
  }
46
31
  }
@@ -145,7 +145,6 @@ export default class Sidebar extends SidebarBase {
145
145
  }
146
146
 
147
147
  renderedCallback() {
148
- super.renderedCallback()
149
148
  this.initializeSearchScrollPosition();
150
149
  }
151
150
 
@@ -81,10 +81,6 @@ export default class Sidebar extends SidebarBase {
81
81
  this.matchMedia.addEventListener("change", this.onMediaChange);
82
82
  }
83
83
 
84
- renderedCallback(): void {
85
- super.renderedCallback();
86
- }
87
-
88
84
  disconnectedCallback() {
89
85
  this.matchMedia.removeEventListener("change", this.onMediaChange);
90
86
  }