playbook_ui 16.9.0.pre.alpha.PLAY3011datepickertimepickerportalling17140 → 16.9.0.pre.alpha.PLAY3027advancedtablestickyactioncolumnvisbar17109

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.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +2 -1
  3. data/app/pb_kits/playbook/pb_advanced_table/Components/TableActionBar.tsx +5 -2
  4. data/app/pb_kits/playbook/pb_advanced_table/Context/AdvancedTableContext.tsx +27 -2
  5. data/app/pb_kits/playbook/pb_advanced_table/Utilities/StickyLayoutHelper.ts +100 -0
  6. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +36 -1
  7. data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.tsx +29 -0
  8. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +7 -0
  9. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +50 -0
  10. data/app/pb_kits/playbook/pb_advanced_table/advanced_table_action_bar.js +31 -9
  11. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sticky_header.jsx +303 -27
  12. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sticky_header_rails.html.erb +205 -31
  13. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header.html.erb +36 -44
  14. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header.jsx +10 -19
  15. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_rails.md +0 -4
  16. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_sticky_header_react.md +3 -5
  17. data/app/pb_kits/playbook/pb_advanced_table/index.js +20 -29
  18. data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +1 -1
  19. data/app/pb_kits/playbook/pb_date_picker/_date_picker.scss +0 -6
  20. data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +2 -16
  21. data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +1 -58
  22. data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +64 -310
  23. data/app/pb_kits/playbook/pb_dialog/_dialog.scss +1 -54
  24. data/app/pb_kits/playbook/pb_dialog/_dialog.tsx +5 -21
  25. data/app/pb_kits/playbook/pb_dialog/_dialog_context.tsx +2 -8
  26. data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.tsx +1 -1
  27. data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +1 -5
  28. data/app/pb_kits/playbook/pb_dialog/dialog.test.jsx +0 -125
  29. data/app/pb_kits/playbook/pb_dialog/index.js +1 -11
  30. data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +0 -8
  31. data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +31 -101
  32. data/app/pb_kits/playbook/pb_dropdown/index.js +25 -219
  33. data/app/pb_kits/playbook/pb_dropdown/keyboard_accessibility.js +10 -9
  34. data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownContainer.tsx +2 -39
  35. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.scss +7 -7
  36. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +10 -125
  37. data/app/pb_kits/playbook/pb_popover/_popover.scss +0 -27
  38. data/app/pb_kits/playbook/pb_popover/_popover.tsx +16 -49
  39. data/app/pb_kits/playbook/pb_popover/index.ts +4 -35
  40. data/app/pb_kits/playbook/pb_popover/popover.html.erb +2 -5
  41. data/app/pb_kits/playbook/pb_popover/popover.test.js +5 -212
  42. data/app/pb_kits/playbook/pb_time_picker/_time_picker.scss +0 -42
  43. data/app/pb_kits/playbook/pb_time_picker/_time_picker.tsx +167 -309
  44. data/app/pb_kits/playbook/pb_time_picker/index.ts +11 -263
  45. data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +3 -109
  46. data/app/pb_kits/playbook/pb_typeahead/kit.schema.json +0 -6
  47. data/dist/chunks/{_pb_line_graph-Dlb5efGq.js → _pb_line_graph-D8PSzzEY.js} +1 -1
  48. data/dist/chunks/_typeahead-CuXG_NFx.js +5 -0
  49. data/dist/chunks/{globalProps-CymGbY5A.js → globalProps-B8stOeTI.js} +1 -1
  50. data/dist/chunks/{lib-CSsX8NUd.js → lib-BAri19Ko.js} +2 -2
  51. data/dist/chunks/time_picker_helper-CVMV9ync.js +1 -0
  52. data/dist/chunks/vendor.js +5 -5
  53. data/dist/playbook-rails-react-bindings.js +1 -1
  54. data/dist/playbook-rails.js +1 -1
  55. data/dist/playbook.css +1 -1
  56. data/lib/playbook/version.rb +1 -1
  57. metadata +8 -8
  58. data/app/pb_kits/playbook/utilities/floatingPortalHosts.ts +0 -565
  59. data/dist/chunks/_typeahead-CSnqqORf.js +0 -5
  60. data/dist/chunks/time_picker_helper-Bx8nzyM8.js +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33a9d2e80c1caf913c3ffe776626ca4fc00a3e8b9c84a9e61c4eb51a35d7213a
4
- data.tar.gz: d9f4a72a0aafe754b769792dd29c4a253a864d888f9ca23fb50246a18c62e23a
3
+ metadata.gz: 1170d3e8d9859ad6a2009997a4730ba0d2e1e2c11dbe075bb4c2ebddd4fb7c62
4
+ data.tar.gz: d5e4f2cdc2bae585c702408327de2759a46991209b0c21ef9fee0107875ec948
5
5
  SHA512:
6
- metadata.gz: a993c299c8c01eda50f73f47d27b412d52258306269b6b898b0e8bd99abd0db7b2151a43327bf57344b9ce73a6bd8027978d5cd3a171803fe21f0f98cac17faa
7
- data.tar.gz: 630b1cebfebf664f4659d5e9112bb3d192e8dcae8ba3b22a48756d7894da60d047a29ab7e176bb2304982176d7a3978cb1e6eb9d35a560b59965ae3fe6a827b7
6
+ metadata.gz: be6b4ea315a20a436bc9f8fc4ea13cccbdcd09f69400cbdc52c124fabc85276617e8c4067da8433e85a155003658daf54656b71db2c32a0528b0262a150d7d05
7
+ data.tar.gz: 99171bbc5a8d3b9cfea7b3521d4b151dcd3a57293b6439b953f9417cfee3c3c000aea61bec26b5474e7e8c4589acf89ce10ec0d376ed8a248156f1bdc891ec73
@@ -136,6 +136,7 @@ export const RegularTableView = ({
136
136
  pinnedRows,
137
137
  headerHeight,
138
138
  rowHeight,
139
+ actionBarHeight,
139
140
  rowStyling = [],
140
141
  sampleRowRef,
141
142
  } = useContext(AdvancedTableContext)
@@ -172,7 +173,7 @@ export const RegularTableView = ({
172
173
  position: 'sticky',
173
174
  top:
174
175
  row.getIsPinned() === 'top'
175
- ? `${row.getPinnedIndex() * rowHeight + headerHeight}px`
176
+ ? `${row.getPinnedIndex() * rowHeight + headerHeight + actionBarHeight}px`
176
177
  : undefined,
177
178
  zIndex: '3'
178
179
  }}
@@ -17,6 +17,7 @@ import {
17
17
  showActionBar,
18
18
  hideActionBar,
19
19
  } from "../Utilities/ActionBarAnimationHelper";
20
+ import { scheduleStickyActionBarHeightUpdate } from "../Utilities/StickyLayoutHelper";
20
21
  import { GenericObject } from "../../types";
21
22
 
22
23
  interface TableActionBarProps {
@@ -39,7 +40,7 @@ const TableActionBar: React.FC<TableActionBarProps> = ({
39
40
  type = "row-selection",
40
41
  }) => {
41
42
  const cardRef = useRef(null);
42
- const { table, columnVisibilityControl, columnDefinitions } =
43
+ const { table, columnVisibilityControl, columnDefinitions, tableContainerRef } =
43
44
  useContext(AdvancedTableContext);
44
45
 
45
46
  // ----------- Column visibility logic -----------
@@ -131,8 +132,10 @@ const TableActionBar: React.FC<TableActionBarProps> = ({
131
132
  } else {
132
133
  hideActionBar(cardRef.current);
133
134
  }
135
+
136
+ scheduleStickyActionBarHeightUpdate(tableContainerRef?.current ?? null);
134
137
  }
135
- }, [isVisible, type]);
138
+ }, [isVisible, type, tableContainerRef]);
136
139
 
137
140
  const [showPopover, setShowPopover] = useState(false)
138
141
 
@@ -4,6 +4,7 @@ import { useVirtualizer } from '@tanstack/react-virtual';
4
4
  import { Row } from "@tanstack/react-table";
5
5
  import { GenericObject } from "../../types";
6
6
  import { getRowHeightEstimate } from '../Utilities/TableContainerStyles';
7
+ import { measureElementHeight } from '../Utilities/StickyLayoutHelper';
7
8
 
8
9
  const AdvancedTableContext = createContext<any>({});
9
10
 
@@ -30,8 +31,11 @@ export const AdvancedTableProvider = ({ children, ...props }: {
30
31
 
31
32
  const [headerHeight, setHeaderHeight] = useState(44);
32
33
  const [rowHeight, setRowHeight] = useState(38);
34
+ const [actionBarHeight, setActionBarHeight] = useState(0);
33
35
 
34
36
  const measureHeights = useCallback(() => {
37
+ const wrapper = (props.tableContainerRef?.current || tableContainerRef.current) as HTMLElement | null;
38
+
35
39
  if (headerRef.current) {
36
40
  const headerElement = headerRef.current as HTMLElement;
37
41
  const headerRect = headerElement.getBoundingClientRect();
@@ -45,7 +49,21 @@ export const AdvancedTableProvider = ({ children, ...props }: {
45
49
  setRowHeight(rowRect.height);
46
50
  }
47
51
  }
48
- }, []);
52
+
53
+ if (wrapper) {
54
+ const actionBar = wrapper.querySelector(
55
+ ".row-selection-actions-card.is-visible, .row-selection-actions-card.show-action-card"
56
+ ) as HTMLElement | null;
57
+ const measuredActionBarHeight = actionBar
58
+ ? measureElementHeight(actionBar)
59
+ : 0;
60
+ setActionBarHeight(measuredActionBarHeight);
61
+ wrapper.style.setProperty(
62
+ "--advanced-table-action-bar-height",
63
+ `${measuredActionBarHeight}px`
64
+ );
65
+ }
66
+ }, [props.tableContainerRef]);
49
67
 
50
68
  useEffect(() => {
51
69
  const resizeObserver = new ResizeObserver(() => {
@@ -56,6 +74,12 @@ export const AdvancedTableProvider = ({ children, ...props }: {
56
74
  resizeObserver.observe(headerRef.current);
57
75
  }
58
76
 
77
+ const wrapper = (props.tableContainerRef?.current || tableContainerRef.current) as HTMLElement | null;
78
+ const actionBar = wrapper?.querySelector(".row-selection-actions-card");
79
+ if (actionBar) {
80
+ resizeObserver.observe(actionBar);
81
+ }
82
+
59
83
  if (sampleRowRef.current) {
60
84
  resizeObserver.observe(sampleRowRef.current);
61
85
  }
@@ -72,7 +96,7 @@ export const AdvancedTableProvider = ({ children, ...props }: {
72
96
 
73
97
  useEffect(() => {
74
98
  measureHeights();
75
- }, [table?.getRowModel().rows.length, headerGroupCount, measureHeights]);
99
+ }, [table?.getRowModel().rows.length, headerGroupCount, props.isActionBarVisible, measureHeights]);
76
100
 
77
101
 
78
102
  // Create a flattened data array that includes ALL components for virtualization
@@ -202,6 +226,7 @@ export const AdvancedTableProvider = ({ children, ...props }: {
202
226
  keepPinnedRows: props.keepPinnedRows,
203
227
  headerHeight,
204
228
  rowHeight,
229
+ actionBarHeight,
205
230
  headerRef,
206
231
  sampleRowRef,
207
232
  measureHeights,
@@ -0,0 +1,100 @@
1
+ const VISIBLE_ACTION_BAR_SELECTOR =
2
+ ".row-selection-actions-card.is-visible, .row-selection-actions-card.show-action-card";
3
+
4
+ const ACTION_BAR_HEIGHT_TRANSITION_MS = 350;
5
+
6
+ export const measureElementHeight = (element: HTMLElement): number => {
7
+ const { height: rectHeight } = element.getBoundingClientRect();
8
+ const scrollHeight = element.scrollHeight;
9
+ const offsetHeight = element.offsetHeight;
10
+
11
+ return Math.ceil(Math.max(rectHeight, scrollHeight, offsetHeight));
12
+ };
13
+
14
+ export const updateStickyActionBarHeight = (
15
+ advancedTableWrapper: HTMLElement | null
16
+ ): number => {
17
+ if (!advancedTableWrapper) return 0;
18
+
19
+ const actionBar = advancedTableWrapper.querySelector(
20
+ VISIBLE_ACTION_BAR_SELECTOR
21
+ ) as HTMLElement | null;
22
+
23
+ if (!actionBar) {
24
+ advancedTableWrapper.style.setProperty(
25
+ "--advanced-table-action-bar-height",
26
+ "0px"
27
+ );
28
+ return 0;
29
+ }
30
+
31
+ const actionBarHeight = measureElementHeight(actionBar);
32
+
33
+ advancedTableWrapper.style.setProperty(
34
+ "--advanced-table-action-bar-height",
35
+ `${actionBarHeight}px`
36
+ );
37
+
38
+ return actionBarHeight;
39
+ };
40
+
41
+ export const scheduleStickyActionBarHeightUpdate = (
42
+ advancedTableWrapper: HTMLElement | null
43
+ ): void => {
44
+ if (!advancedTableWrapper) return;
45
+
46
+ updateStickyActionBarHeight(advancedTableWrapper);
47
+
48
+ requestAnimationFrame(() => {
49
+ updateStickyActionBarHeight(advancedTableWrapper);
50
+ requestAnimationFrame(() => {
51
+ updateStickyActionBarHeight(advancedTableWrapper);
52
+ });
53
+ });
54
+
55
+ window.setTimeout(() => {
56
+ updateStickyActionBarHeight(advancedTableWrapper);
57
+ }, ACTION_BAR_HEIGHT_TRANSITION_MS);
58
+ };
59
+
60
+ export const updateStickyHeaderRowHeights = (
61
+ advancedTableWrapper: HTMLElement | null
62
+ ): void => {
63
+ if (!advancedTableWrapper) return;
64
+
65
+ const table = advancedTableWrapper.querySelector("table.pb_table");
66
+ const thead = table?.querySelector("thead");
67
+ if (!thead) return;
68
+
69
+ const rows = Array.from(thead.querySelectorAll("tr"));
70
+ let totalHeight = 0;
71
+
72
+ rows.forEach((tr, index) => {
73
+ const height = tr.offsetHeight;
74
+ if (index === 0) {
75
+ advancedTableWrapper.style.setProperty(
76
+ "--advanced-table-header-row-0-height",
77
+ `${height}px`
78
+ );
79
+ } else if (index === 1) {
80
+ advancedTableWrapper.style.setProperty(
81
+ "--advanced-table-header-row-1-height",
82
+ `${height}px`
83
+ );
84
+ }
85
+ totalHeight += height;
86
+ });
87
+
88
+ advancedTableWrapper.style.setProperty(
89
+ "--advanced-table-header-height",
90
+ `${totalHeight}px`
91
+ );
92
+
93
+ updateStickyActionBarHeight(advancedTableWrapper);
94
+ };
95
+
96
+ export const updateStickyLayoutHeights = (
97
+ advancedTableWrapper: HTMLElement | null
98
+ ): void => {
99
+ updateStickyHeaderRowHeights(advancedTableWrapper);
100
+ };
@@ -364,6 +364,34 @@
364
364
  }
365
365
  }
366
366
 
367
+ &.advanced-table-sticky-header {
368
+ .row-selection-actions-card.show-action-card,
369
+ .row-selection-actions-card.is-visible {
370
+ background-color: $white;
371
+ left: 0;
372
+ position: sticky;
373
+ top: 0;
374
+ z-index: 5;
375
+ }
376
+
377
+ .pb_table.sticky-header {
378
+ thead,
379
+ .pb_advanced_table_header {
380
+ top: var(--advanced-table-action-bar-height, 0px);
381
+ z-index: 3;
382
+ }
383
+ }
384
+
385
+ &.hidden-action-bar {
386
+ .pb_table.sticky-header {
387
+ thead,
388
+ .pb_advanced_table_header {
389
+ top: 0;
390
+ }
391
+ }
392
+ }
393
+ }
394
+
367
395
  // Max height overflow - the below prevents expansion from overflowing container at full screen for responsive and nonresponsive tables
368
396
  &.advanced-table-max-height-xs {
369
397
  max-height: 320px;
@@ -434,7 +462,7 @@
434
462
  thead,
435
463
  .pb_advanced_table_header {
436
464
  position: sticky !important;
437
- top: 44px !important;
465
+ top: calc(44px + var(--advanced-table-action-bar-height, 0px)) !important;
438
466
  z-index: $z_10;
439
467
  }
440
468
  }
@@ -987,6 +1015,13 @@
987
1015
  background-color: $bg_dark_card;
988
1016
  }
989
1017
 
1018
+ &.advanced-table-sticky-header {
1019
+ .row-selection-actions-card.show-action-card,
1020
+ .row-selection-actions-card.is-visible {
1021
+ background-color: $bg_dark_card;
1022
+ }
1023
+ }
1024
+
990
1025
  .loading-toggle-icon,
991
1026
  .loading-cell {
992
1027
  &::after {
@@ -18,6 +18,7 @@ import TableActionBar from "./Components/TableActionBar";
18
18
 
19
19
  import { useTableState } from "./Hooks/useTableState";
20
20
  import { useTableActions } from "./Hooks/useTableActions";
21
+ import { updateStickyLayoutHeights, scheduleStickyActionBarHeightUpdate } from "./Utilities/StickyLayoutHelper";
21
22
 
22
23
  import Card from "../pb_card/_card"
23
24
  import Flex from "../pb_flex/_flex"
@@ -283,6 +284,33 @@ const AdvancedTable = (props: AdvancedTableProps) => {
283
284
 
284
285
  // Visibility flag for action bar
285
286
  const isActionBarVisible = (selectableRows && showActionsBar && selectedRowsLength > 0) || columnVisibilityControl;
287
+ const isStickyHeader = Boolean(tableProps?.sticky);
288
+
289
+ useEffect(() => {
290
+ if (!isStickyHeader || !tableWrapperRef.current) return;
291
+
292
+ const wrapper = tableWrapperRef.current;
293
+ const updateHeights = () => updateStickyLayoutHeights(wrapper);
294
+
295
+ updateHeights();
296
+ scheduleStickyActionBarHeightUpdate(wrapper);
297
+
298
+ const resizeObserver = new ResizeObserver(updateHeights);
299
+ resizeObserver.observe(wrapper);
300
+
301
+ const actionBar = wrapper.querySelector(".row-selection-actions-card");
302
+ if (actionBar) {
303
+ resizeObserver.observe(actionBar);
304
+ }
305
+
306
+ const table = wrapper.querySelector("table.pb_table");
307
+ const thead = table?.querySelector("thead");
308
+ if (thead) {
309
+ resizeObserver.observe(thead);
310
+ }
311
+
312
+ return () => resizeObserver.disconnect();
313
+ }, [isStickyHeader, isActionBarVisible, columnDefinitions, tableData]);
286
314
 
287
315
  const classes = classnames(
288
316
  buildCss("pb_advanced_table"),
@@ -295,6 +323,7 @@ const AdvancedTable = (props: AdvancedTableProps) => {
295
323
  'hidden-action-bar': (selectableRows || columnVisibilityControl) && !isActionBarVisible,
296
324
  },
297
325
  {'advanced-table-sticky-left-columns': stickyLeftColumn && stickyLeftColumn.length > 0},
326
+ { 'advanced-table-sticky-header': isStickyHeader },
298
327
  { 'advanced-table-no-table-container': noTableCardContainer },
299
328
  columnGroupBorderColor ? `column-group-border-${columnGroupBorderColor}` : '',
300
329
  scrollBarNone ? 'advanced-table-hide-scrollbar' : '',
@@ -46,6 +46,7 @@ module Playbook
46
46
  max_height_classname,
47
47
  hide_scroll_bar_class,
48
48
  hidden_action_bar_class,
49
+ sticky_header_class,
49
50
  ]
50
51
  additional_classes << "column-group-border-#{column_group_border_color}" if column_group_border_color != "none"
51
52
  additional_classes << "advanced-table-no-table-container" if no_table_card_container?
@@ -75,6 +76,12 @@ module Playbook
75
76
  selectable_rows && !is_action_bar_visible ? "hidden-action-bar" : ""
76
77
  end
77
78
 
79
+ def sticky_header_class
80
+ return "" unless table_props.is_a?(Hash)
81
+
82
+ table_props[:sticky] || table_props["sticky"] ? "advanced-table-sticky-header" : ""
83
+ end
84
+
78
85
  def selected_rows
79
86
  @selected_rows ||= []
80
87
  end
@@ -418,6 +418,56 @@ test("tableProps prop functions as expected", () => {
418
418
  const kit = screen.getByTestId(testId)
419
419
  const table = kit.querySelector('table')
420
420
  expect(table).toHaveClass("pb_table table-sm table-responsive-none data_table sticky-header ns_tabular")
421
+ expect(kit).toHaveClass("advanced-table-sticky-header")
422
+ })
423
+
424
+ test("sticky header with column visibility control offsets layout heights", async () => {
425
+ const columnDefsWithIds = columnDefinitions.map((col) => ({
426
+ ...col,
427
+ id: col.accessor,
428
+ }))
429
+
430
+ render(
431
+ <AdvancedTable
432
+ columnDefinitions={columnDefsWithIds}
433
+ columnVisibilityControl={{ default: true }}
434
+ data={{ testid: testId }}
435
+ responsive="none"
436
+ tableData={MOCK_DATA}
437
+ tableProps={{ sticky: true }}
438
+ />
439
+ )
440
+
441
+ const kit = screen.getByTestId(testId)
442
+ expect(kit).toHaveClass("advanced-table-sticky-header")
443
+ expect(kit).not.toHaveClass("hidden-action-bar")
444
+
445
+ const actionBar = kit.querySelector(".row-selection-actions-card.show-action-card")
446
+ expect(actionBar).toBeInTheDocument()
447
+
448
+ await waitFor(() => {
449
+ expect(kit.style.getPropertyValue("--advanced-table-action-bar-height")).toMatch(/^\d+px$/)
450
+ })
451
+ })
452
+
453
+ test("sticky header without column visibility control keeps zero action bar offset", async () => {
454
+ render(
455
+ <AdvancedTable
456
+ columnDefinitions={columnDefinitions}
457
+ data={{ testid: testId }}
458
+ responsive="none"
459
+ tableData={MOCK_DATA}
460
+ tableProps={{ sticky: true }}
461
+ />
462
+ )
463
+
464
+ const kit = screen.getByTestId(testId)
465
+ expect(kit).toHaveClass("advanced-table-sticky-header")
466
+ expect(kit).not.toHaveClass("hidden-action-bar")
467
+
468
+ await waitFor(() => {
469
+ expect(kit.style.getPropertyValue("--advanced-table-action-bar-height")).toBe("0px")
470
+ })
421
471
  })
422
472
 
423
473
  test("enableExpansionIcon changes icon", () => {
@@ -1,26 +1,44 @@
1
+ import {
2
+ scheduleStickyActionBarHeightUpdate,
3
+ updateStickyActionBarHeight,
4
+ } from "./Utilities/StickyLayoutHelper";
5
+
6
+ // Card kit defaults to `transition-property: all`, which can animate height/opacity
7
+ // during expand/collapse. Limit transitions to decorative properties only.
8
+ const ACTION_BAR_TRANSITION_PROPERTIES = "border-color, box-shadow";
9
+
1
10
  function showActionBar(actionBar, selectedCount) {
2
11
  // Get container
3
12
  const tableContainer = actionBar.closest('.pb_advanced_table');
4
13
 
5
- // Show action bar directly
6
- actionBar.style.height = "auto";
14
+ // Update the count before measuring height so the label is included on first show
15
+ const countElement = actionBar.querySelector(".selected-count");
16
+ if (countElement) {
17
+ countElement.textContent = `${selectedCount} Selected`;
18
+ }
19
+
20
+ // Expand without animating height so sticky offsets measure the final size
21
+ actionBar.style.transitionProperty = "none";
7
22
  actionBar.style.overflow = "visible";
8
23
  actionBar.style.opacity = "1";
9
- actionBar.style.transitionProperty = "all";
10
- actionBar.style.transitionTimingFunction = "ease-in-out";
11
24
  actionBar.classList.remove("p_none");
12
25
  actionBar.classList.add("p_xs", "is-visible", "show-action-card");
26
+ actionBar.style.height = "auto";
27
+
28
+ // Force layout so padding/content are included before measuring
29
+ void actionBar.offsetHeight;
30
+
31
+ const expandedHeight = actionBar.scrollHeight;
32
+ actionBar.style.height = `${expandedHeight}px`;
13
33
 
14
34
  // Remove hidden-action-bar class when action bar is shown
15
35
  if (tableContainer) {
16
36
  tableContainer.classList.remove("hidden-action-bar");
37
+ updateStickyActionBarHeight(tableContainer);
38
+ scheduleStickyActionBarHeightUpdate(tableContainer);
17
39
  }
18
40
 
19
- // Update the count
20
- const countElement = actionBar.querySelector(".selected-count");
21
- if (countElement) {
22
- countElement.textContent = `${selectedCount} Selected`;
23
- }
41
+ actionBar.style.transitionProperty = ACTION_BAR_TRANSITION_PROPERTIES;
24
42
  }
25
43
 
26
44
  function hideActionBar(actionBar) {
@@ -28,6 +46,7 @@ function hideActionBar(actionBar) {
28
46
  const tableContainer = actionBar.closest('.pb_advanced_table');
29
47
 
30
48
  // Hide action bar directly
49
+ actionBar.style.transitionProperty = "none";
31
50
  actionBar.style.height = "0px";
32
51
  actionBar.style.overflow = "hidden";
33
52
  actionBar.style.opacity = "0";
@@ -37,7 +56,10 @@ function hideActionBar(actionBar) {
37
56
  // Add hidden-action-bar class when action bar is hidden
38
57
  if (tableContainer) {
39
58
  tableContainer.classList.add("hidden-action-bar");
59
+ updateStickyActionBarHeight(tableContainer);
40
60
  }
61
+
62
+ actionBar.style.transitionProperty = ACTION_BAR_TRANSITION_PROPERTIES;
41
63
  }
42
64
 
43
65
  export function updateSelectionActionBar(table, selectedCount) {