playbook_ui 13.21.0.pre.alpha.pbntr220improveexpansionspeed2451 → 13.21.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 53ec5eba2bcbca69770aff3a4995d6acebd6837d3e47ca43f6e65a075945114f
4
- data.tar.gz: 6834eef7adb98d03a39e1b9fc62eb0cf6c3d419d884a8aa55047898169b49bfe
3
+ metadata.gz: e6c19fad05505af542ad2b4998d9d9d6f225ad3b46568420e87f7a3d72847cf2
4
+ data.tar.gz: '05208a0115fc90b97569c6c96c3847211b2136550f95817eb2dd8eb3eac2c90a'
5
5
  SHA512:
6
- metadata.gz: 8192c971c521ec1a33906219fc0cab51b8c325b722a9c1339743d2f0702f9584a7edd3a27e850fedd45f6262b197a41f5a4ad3c0a132e790870eb62c430560f5
7
- data.tar.gz: 89019b191251d20c60eb613df60e14ac50dee6567b552b274d0bb03979817a4a4026538229b7e41be05d50000373f2fbb430bc30035a231279f5d676f975fac3
6
+ metadata.gz: adad3d8a3607b475d9f16c1cc34ee1937fb52b4d2e3af4c7dd481a5a258ba972aa6df89bcbc1c59bb833300b3b9ff9d5988741321bfb5908d6e3706449f7b397
7
+ data.tar.gz: 1636c11fdc69b49524df0d8c0d17e91dc732f356fe279b78fc90287053bec7c7529377376acd1cb22d2b6903552d1ea448e91e3730c2738b47f62fdc4a15452e
@@ -15,27 +15,42 @@ export const updateExpandAndCollapseState = (
15
15
  expanded: Record<string, boolean>,
16
16
  targetParent: string
17
17
  ) => {
18
- const updateExpandedRows: Record<string, boolean> = {};
19
- const rows = tableRows.rows;
20
-
21
- let isExpansionConsistent = true;
22
- const areRowsExpanded = new Set<boolean>();
18
+ const updateExpandedRows: Record<string, boolean> = {}
19
+ const rows = tableRows.flatRows
20
+ // Variable checks if all rows in a section have same expansion state or not
21
+ let isExpansionConsistent = true
22
+ const areRowsExpanded = new Set<boolean>()
23
23
 
24
+ // Update isExpansionConsistent variable
24
25
  for (const row of rows) {
25
- const shouldBeUpdated = targetParent === undefined ? row.depth === 0 : targetParent === row.parentId;
26
-
27
- if (shouldBeUpdated) {
28
- const isExpanded = row.getIsExpanded();
29
- areRowsExpanded.add(isExpanded);
30
-
31
- updateExpandedRows[row.id] = !isExpansionConsistent ? true : !isExpanded;
32
-
26
+ if (
27
+ targetParent === undefined
28
+ ? row.depth === 0
29
+ : targetParent === row.parentId
30
+ ) {
31
+ areRowsExpanded.add(row.getIsExpanded())
33
32
  if (areRowsExpanded.size > 1) {
34
- isExpansionConsistent = false;
35
- // If expansion inconsistent, ensure all target rows are set to expand
36
- for (const key in updateExpandedRows) {
37
- updateExpandedRows[key] = true;
38
- }
33
+ isExpansionConsistent = false
34
+ break
35
+ }
36
+ }
37
+ }
38
+
39
+ // The if statement runs only for row depth 0, the else statement for the rest
40
+ if (targetParent === undefined) {
41
+ rows.forEach(row => {
42
+ if (row.depth === 0) {
43
+ updateExpandedRows[row.id] = !isExpansionConsistent
44
+ ? true
45
+ : !row.getIsExpanded()
46
+ }
47
+ })
48
+ } else {
49
+ for (const row of rows) {
50
+ if (targetParent === row.parentId) {
51
+ updateExpandedRows[row.id] = !isExpansionConsistent
52
+ ? true
53
+ : !row.getIsExpanded()
39
54
  }
40
55
  }
41
56
  }
@@ -43,5 +58,5 @@ export const updateExpandAndCollapseState = (
43
58
  return filterExpandableRows({
44
59
  ...(expanded as ExpandedStateObject),
45
60
  ...updateExpandedRows,
46
- });
47
- };
61
+ })
62
+ }
@@ -191,13 +191,14 @@ const AdvancedTable = (props: AdvancedTableProps) => {
191
191
  }
192
192
  }, [loading, updateLoadingStateRowCount]);
193
193
 
194
- const handleExpandOrCollapse = async (row: Row<DataType>) => {
194
+ const handleExpandOrCollapse = (row: Row<DataType>) => {
195
195
  onToggleExpansionClick && onToggleExpansionClick(row);
196
-
196
+
197
197
  const expandedState = expanded;
198
198
  const targetParent = row?.parentId;
199
- const updatedRows = await updateExpandAndCollapseState(tableRows, expandedState, targetParent);
200
- setExpanded(updatedRows);
199
+ return setExpanded(
200
+ updateExpandAndCollapseState(tableRows, expandedState, targetParent)
201
+ );
201
202
  };
202
203
 
203
204
  const ariaProps = buildAriaProps(aria);
@@ -1,5 +1,5 @@
1
1
  import React, {useState} from "react";
2
- import { render, screen, waitFor } from "../utilities/test-utils";
2
+ import { render, screen } from "../utilities/test-utils";
3
3
 
4
4
  import { AdvancedTable } from "../";
5
5
 
@@ -198,7 +198,7 @@ test("Row toggle button exists and toggles subrows open and closed", () => {
198
198
  expect(subRow).toBeInTheDocument()
199
199
  });
200
200
 
201
- test("toggleExpansionAll button exists and toggles subrows open and closed", async () => {
201
+ test("toggleExpansionAll button exists and toggles subrows open and closed", () => {
202
202
  render(
203
203
  <AdvancedTable
204
204
  columnDefinitions={columnDefinitions}
@@ -208,21 +208,15 @@ test("toggleExpansionAll button exists and toggles subrows open and closed", asy
208
208
  );
209
209
 
210
210
  const kit = screen.getByTestId(testId);
211
- const toggleButton = kit.querySelector(".gray-icon.toggle-all-icon");
212
- expect(toggleButton).toBeInTheDocument();
213
-
214
- const subRow1 = kit.querySelector(".bg-white.depth-sub-row-1");
215
- expect(subRow1).not.toBeInTheDocument();
216
-
217
- toggleButton.click();
218
-
219
- await waitFor(() => {
220
- const subRow = kit.querySelector(".bg-white.depth-sub-row-1");
221
- expect(subRow).toBeInTheDocument();
222
- });
211
+ const toggleButton = kit.querySelector(".gray-icon.toggle-all-icon")
212
+ expect(toggleButton).toBeInTheDocument()
213
+ const subRow1 = kit.querySelector(".bg-white.depth-sub-row-1")
214
+ expect(subRow1).not.toBeInTheDocument()
215
+ toggleButton.click()
216
+ const subRow = kit.querySelector(".bg-white.depth-sub-row-1")
217
+ expect(subRow).toBeInTheDocument()
223
218
  });
224
219
 
225
-
226
220
  test("loading state + initialLoadingRowCount prop", () => {
227
221
  render(
228
222
  <AdvancedTable
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Playbook
4
- PREVIOUS_VERSION = "13.21.0"
5
- VERSION = "13.21.0.pre.alpha.pbntr220improveexpansionspeed2451"
4
+ PREVIOUS_VERSION = "13.20.0"
5
+ VERSION = "13.21.0"
6
6
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playbook_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.21.0.pre.alpha.pbntr220improveexpansionspeed2451
4
+ version: 13.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Power UX
8
8
  - Power Devs
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-03-22 00:00:00.000000000 Z
12
+ date: 2024-03-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -2874,7 +2874,7 @@ homepage: https://playbook.powerapp.cloud/
2874
2874
  licenses:
2875
2875
  - ISC
2876
2876
  metadata: {}
2877
- post_install_message:
2877
+ post_install_message:
2878
2878
  rdoc_options: []
2879
2879
  require_paths:
2880
2880
  - lib
@@ -2885,12 +2885,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
2885
2885
  version: '0'
2886
2886
  required_rubygems_version: !ruby/object:Gem::Requirement
2887
2887
  requirements:
2888
- - - ">"
2888
+ - - ">="
2889
2889
  - !ruby/object:Gem::Version
2890
- version: 1.3.1
2890
+ version: '0'
2891
2891
  requirements: []
2892
2892
  rubygems_version: 3.3.7
2893
- signing_key:
2893
+ signing_key:
2894
2894
  specification_version: 4
2895
2895
  summary: Playbook Design System
2896
2896
  test_files: []