• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SAP / ui5-webcomponents-react / 14304969491

07 Apr 2025 08:53AM CUT coverage: 87.54% (+0.08%) from 87.46%
14304969491

Pull #7187

github

web-flow
Merge f9635f7ca into 8d652b4c7
Pull Request #7187: feat(ObjectPage): allow customizing `role` of `footerArea` container

2966 of 3932 branches covered (75.43%)

5185 of 5923 relevant lines covered (87.54%)

84562.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.55
/packages/main/src/components/AnalyticalTable/hooks/useToggleRowExpand.ts
1
import announce from '@ui5/webcomponents-base/dist/util/InvisibleMessage.js';
2
import { debounce, enrichEventWithDetails } from '@ui5/webcomponents-react-base';
3
import type { ReactTableHooks, RowType, TableInstance } from '../types/index.js';
4

5
// debounce announce to prevent excessive successive announcements
6
const debouncedAnnounce = debounce((announcement: string) => {
427✔
7
  announce(announcement, 'Polite');
363✔
8
}, 200);
9

10
const getToggleRowExpandedProps = (
427✔
11
  rowProps,
12
  { row, instance, userProps }: { row: RowType; instance: TableInstance; userProps: Record<string, any> }
13
) => {
14
  const { manualGroupBy } = instance;
740,536✔
15
  const { onRowExpandChange, isTreeTable, renderRowSubComponent, alwaysShowSubComponent, translatableTexts } =
16
    instance.webComponentsReactProperties;
740,536✔
17

18
  const onClick = (e, noPropagation = true) => {
740,536✔
19
    if (noPropagation) {
774✔
20
      e.stopPropagation();
609✔
21
    }
22

23
    let column = null;
774✔
24
    if (!isTreeTable && (!renderRowSubComponent || (renderRowSubComponent && alwaysShowSubComponent))) {
774✔
25
      if (!manualGroupBy) {
130✔
26
        column = row.cells.find((cell) => cell.column.id === row.groupByID)?.column;
202✔
27
      } else {
28
        column = userProps.column;
12✔
29
      }
30
    }
31
    if (typeof onRowExpandChange === 'function') {
774✔
32
      onRowExpandChange(
24✔
33
        enrichEventWithDetails(e, {
34
          row,
35
          column
36
        })
37
      );
38
    }
39
    row.toggleRowExpanded();
774✔
40
    // cannot use ROW_X_COLLAPSED/ROW_X_EXPANDED here,
41
    // as retrieving the index of the row is not easily possible here and has performance implications
42
    debouncedAnnounce(
774✔
43
      !row.isExpanded ? translatableTexts.rowExpandedAnnouncementText : translatableTexts.rowCollapsedAnnouncementText
774✔
44
    );
45
  };
46
  const onKeyDown = (e) => {
740,536✔
47
    if (e.code === 'F4') {
210!
48
      e.preventDefault();
×
49
      onClick(e, false);
×
50
    } else if ((!e.shiftKey && e.code === 'Space') || e.key === 'Enter') {
210✔
51
      // the `onClick` event of the `Icon` component already fires the event on ENTER/SPACE press
52
      if (e.target.hasAttribute('ui5-icon') || e.target.hasAttribute('ui5-button')) {
210✔
53
        return;
45✔
54
      }
55
      e.preventDefault();
165✔
56
      onClick(e, false);
165✔
57
    }
58
  };
59
  const { title: _0, ...toggleRowPropsWithoutTitle } = rowProps;
740,536✔
60
  return [
740,536✔
61
    toggleRowPropsWithoutTitle,
62
    {
63
      onClick,
64
      onKeyDown
65
    }
66
  ];
67
};
68

69
export const useToggleRowExpand = (hooks: ReactTableHooks) => {
427✔
70
  hooks.getToggleRowExpandedProps.push(getToggleRowExpandedProps);
84,334✔
71
};
72
useToggleRowExpand.pluginName = 'useToggleRowExpand';
427✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc