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

SAP / ui5-webcomponents-react / 15471588294

05 Jun 2025 03:51PM CUT coverage: 89.13%. Remained the same
15471588294

Pull #7341

github

web-flow
Merge 18245766a into c749f320b
Pull Request #7341: feat(cli): add experimental `patch-compat-table` command

3048 of 3945 branches covered (77.26%)

5330 of 5980 relevant lines covered (89.13%)

129358.17 hits per line

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

68.57
/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) => {
446✔
5
  const { payload } = action;
246,399✔
6
  if (state.isRtl && action.type === actions.columnResizing) {
246,399!
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) {
246,399!
31
    case 'setFilter': {
32
      const { onFilter } = instance.webComponentsReactProperties;
2,584✔
33
      if (typeof onFilter === 'function') {
2,584✔
34
        instance.webComponentsReactProperties.onFilter({
2,008✔
35
          filters: state.filters,
36
          value: action.filterValue,
37
          columnId: action.columnId,
38
        });
39
      }
40
      return state;
2,584✔
41
    }
42
    case 'toggleRowExpanded':
43
      // this flag disables scrolling to the top of the table if a table is collapsed
44
      if (!state.expanded[action.id]) {
1,704✔
45
        instance.dispatch({
102✔
46
          type: 'ROW_COLLAPSED_FLAG',
47
          payload: true,
48
        });
49
      }
50
      return state;
1,704✔
51
    case 'TABLE_RESIZE':
52
      // tableClientWidth is misleading, as only when scaled the `clientWidth` is used. In all other cases `getBoundingClientRect` is measuring the width.
53
      return { ...state, tableClientWidth: payload.tableClientWidth };
29,944✔
54
    case 'VISIBLE_ROWS':
55
      return { ...state, visibleRows: payload.visibleRows };
3,604✔
56
    case 'TABLE_SCROLLING_ENABLED':
57
      return { ...state, isScrollable: payload.isScrollable };
21,266✔
58
    case 'SET_SELECTED_ROW_IDS':
59
      return { ...state, selectedRowIds: payload.selectedRowIds };
402✔
60
    case 'SET_POPIN_COLUMNS':
61
      return { ...state, popInColumns: payload };
25,583✔
62
    case 'INTERACTIVE_ROWS_HAVE_POPIN':
63
      return { ...state, interactiveRowsHavePopIn: payload };
×
64
    case 'IS_RTL':
65
      return { ...state, isRtl: payload.isRtl };
15,260✔
66
    case 'SUB_COMPONENTS_HEIGHT':
67
      return { ...state, subComponentsHeight: payload };
10,312✔
68
    case 'TABLE_COL_RESIZED':
69
      return { ...state, tableColResized: payload };
×
70
    case 'SELECT_ROW_CB':
71
      return { ...state, selectedRowPayload: payload };
7,260✔
72
    case 'ROW_COLLAPSED_FLAG':
73
      return { ...state, rowCollapsed: payload };
136✔
74
    case 'COLUMN_DND_START':
75
      return { ...state, dndColumn: payload };
×
76
    case 'COLUMN_DND_END':
77
      return { ...state, dndColumn: '' };
132✔
78
    // fallback if the component wasn't ready yet for scrolling (elements are not initialized), e.g. when calling `.scrollToItem` on mount
79
    case 'TRIGGER_PROG_SCROLL':
80
      return { ...state, triggerScroll: payload };
160✔
81
    case 'AUTO_RESIZE':
82
      return {
728✔
83
        ...state,
84
        columnResizing: {
85
          ...state.columnResizing,
86
          columnWidths: {
87
            ...state.columnResizing.columnWidths,
88
            ...payload,
89
          },
90
        },
91
      };
92
    default:
93
      return state;
127,324✔
94
  }
95
};
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