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

SAP / ui5-webcomponents-react / 14861100686

06 May 2025 01:36PM CUT coverage: 88.202% (-0.02%) from 88.224%
14861100686

Pull #7304

github

web-flow
Merge ba1615612 into cbb3a14a4
Pull Request #7304: feat(AnalyticalTable): introduce `onFilter` callback prop

3014 of 3967 branches covered (75.98%)

7 of 7 new or added lines in 2 files covered. (100.0%)

3 existing lines in 2 files now uncovered.

5293 of 6001 relevant lines covered (88.2%)

103769.68 hits per line

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

66.67
/packages/main/src/components/AnalyticalTable/tableReducer/stateReducer.ts
1
import { actions } from 'react-table';
2
import type { TableInstance } from '../types/index.js';
3

4
export const stateReducer = (state, action, _prevState, instance: TableInstance) => {
444✔
5
  const { payload } = action;
251,741✔
6
  if (state.isRtl && action.type === actions.columnResizing) {
251,741!
UNCOV
7
    const { clientX } = action;
×
8
    const { startX, columnWidth, headerIdWidths } = state.columnResizing;
×
9

10
    const deltaX = startX - clientX;
×
11
    const percentageDeltaX = deltaX / columnWidth;
×
12

13
    const newColumnWidths = {};
×
14

15
    headerIdWidths.forEach(([headerId, headerWidth]) => {
×
16
      newColumnWidths[headerId] = Math.max(headerWidth + headerWidth * percentageDeltaX, 0);
×
17
    });
18

19
    return {
×
20
      ...state,
21
      columnResizing: {
22
        ...state.columnResizing,
23
        columnWidths: {
24
          ...state.columnResizing.columnWidths,
25
          ...newColumnWidths
26
        }
27
      }
28
    };
29
  }
30
  switch (action.type) {
251,741!
31
    case 'setFilter':
32
      instance.webComponentsReactProperties.onFilter({
2,528✔
33
        filters: state.filters,
34
        value: action.filterValue,
35
        columnId: action.columnId
36
      });
37
      return state;
2,528✔
38
    case 'toggleRowExpanded':
39
      // this flag disables scrolling to the top of the table if a table is collapsed
40
      if (!state.expanded[action.id]) {
1,672✔
41
        instance.dispatch({
102✔
42
          type: 'ROW_COLLAPSED_FLAG',
43
          payload: true
44
        });
45
      }
46
      return state;
1,672✔
47
    case 'TABLE_RESIZE':
48
      // tableClientWidth is misleading, as only when scaled the `clientWidth` is used. In all other cases `getBoundingClientRect` is measuring the width.
49
      return { ...state, tableClientWidth: payload.tableClientWidth };
29,006✔
50
    case 'VISIBLE_ROWS':
51
      return { ...state, visibleRows: payload.visibleRows };
3,536✔
52
    case 'TABLE_SCROLLING_ENABLED':
53
      return { ...state, isScrollable: payload.isScrollable };
21,036✔
54
    case 'SET_SELECTED_ROW_IDS':
55
      return { ...state, selectedRowIds: payload.selectedRowIds };
392✔
56
    case 'SET_POPIN_COLUMNS':
57
      return { ...state, popInColumns: payload };
28,601✔
58
    case 'INTERACTIVE_ROWS_HAVE_POPIN':
59
      return { ...state, interactiveRowsHavePopIn: payload };
×
60
    case 'IS_RTL':
61
      return { ...state, isRtl: payload.isRtl };
14,946✔
62
    case 'SUB_COMPONENTS_HEIGHT':
63
      return { ...state, subComponentsHeight: payload };
10,308✔
64
    case 'TABLE_COL_RESIZED':
65
      return { ...state, tableColResized: payload };
×
66
    case 'SELECT_ROW_CB':
67
      return { ...state, selectedRowPayload: payload };
7,088✔
68
    case 'ROW_COLLAPSED_FLAG':
69
      return { ...state, rowCollapsed: payload };
136✔
70
    case 'COLUMN_DND_START':
71
      return { ...state, dndColumn: payload };
×
72
    case 'COLUMN_DND_END':
73
      return { ...state, dndColumn: '' };
128✔
74
    // fallback if the component wasn't ready yet for scrolling (elements are not initialized), e.g. when calling `.scrollToItem` on mount
75
    case 'TRIGGER_PROG_SCROLL':
76
      return { ...state, triggerScroll: payload };
160✔
77
    case 'AUTO_RESIZE':
78
      return {
714✔
79
        ...state,
80
        columnResizing: {
81
          ...state.columnResizing,
82
          columnWidths: {
83
            ...state.columnResizing.columnWidths,
84
            ...payload
85
          }
86
        }
87
      };
88
    default:
89
      return state;
131,490✔
90
  }
91
};
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