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

SAP / ui5-webcomponents-react / 7049355146

30 Nov 2023 04:26PM CUT coverage: 87.892% (+0.02%) from 87.873%
7049355146

Pull #5296

github

web-flow
Merge 948f1fb97 into 6e7002d79
Pull Request #5296: fix(AnalyticalTable): don't scroll when calling `toggleRowExpanded`

2848 of 3804 branches covered (0.0%)

17 of 21 new or added lines in 2 files covered. (80.95%)

5154 of 5864 relevant lines covered (87.89%)

28760.14 hits per line

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

62.07
/packages/main/src/components/AnalyticalTable/tableReducer/stateReducer.ts
1
import { actions } from 'react-table';
2

3
export const stateReducer = (state, action, _prevState, instance) => {
418✔
4
  const { payload } = action;
55,757✔
5

6
  if (state.isRtl && action.type === actions.columnResizing) {
55,757!
7
    const { clientX } = action;
×
NEW
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) {
55,757!
31
    case 'toggleRowExpanded':
32
      // this flag disables scrolling to the top of the table if a table is collapsed
33
      if (!state.expanded[action.id]) {
513✔
34
        instance.dispatch({
27✔
35
          type: 'ROW_COLLAPSED_FLAG',
36
          payload: true
37
        });
38
      }
39
      return state;
513✔
40
    case 'TABLE_RESIZE':
41
      return { ...state, tableClientWidth: payload.tableClientWidth };
8,048✔
42
    case 'VISIBLE_ROWS':
43
      return { ...state, visibleRows: payload.visibleRows };
1,134✔
44
    case 'TABLE_SCROLLING_ENABLED':
45
      return { ...state, isScrollable: payload.isScrollable };
3,714✔
46
    case 'SET_SELECTED_ROW_IDS':
47
      return { ...state, selectedRowIds: payload.selectedRowIds };
1,790✔
48
    case 'SET_POPIN_COLUMNS':
49
      return { ...state, popInColumns: payload };
10,339✔
50
    case 'INTERACTIVE_ROWS_HAVE_POPIN':
NEW
51
      return { ...state, interactiveRowsHavePopIn: payload };
×
52
    case 'IS_RTL':
53
      return { ...state, isRtl: payload.isRtl };
2,078✔
54
    case 'SUB_COMPONENTS_HEIGHT':
55
      return { ...state, subComponentsHeight: payload };
1,792✔
56
    case 'TABLE_COL_RESIZED':
NEW
57
      return { ...state, tableColResized: payload };
×
58
    case 'SELECT_ROW_CB':
59
      return { ...state, selectedRowPayload: payload };
2,747✔
60
    case 'ROW_COLLAPSED_FLAG':
61
      return { ...state, rowCollapsed: payload };
36✔
62
    case 'COLUMN_DND_START':
NEW
63
      return { ...state, dndColumn: payload };
×
64
    case 'COLUMN_DND_END':
65
      return { ...state, dndColumn: '' };
48✔
66
    default:
67
      return state;
23,518✔
68
  }
69
};
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