Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit fc77aec

Browse files
author
Shammamah Hossain
committed
Add loading state check to computation of cell contents.
1 parent 60c952f commit fc77aec

2 files changed

Lines changed: 22 additions & 13 deletions

File tree

src/dash-table/components/CellFactory.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ export default class CellFactory {
5151
style_data,
5252
style_data_conditional,
5353
virtualized,
54-
visibleColumns
54+
visibleColumns,
55+
loading_state
5556
} = this.props;
5657

5758
const relevantStyles = this.relevantStyles(
@@ -118,7 +119,8 @@ export default class CellFactory {
118119
virtualized.data,
119120
virtualized.offset,
120121
!!is_focused,
121-
dropdowns
122+
dropdowns,
123+
loading_state
122124
);
123125

124126
const cellContents = this.cellContents.get(
@@ -128,7 +130,8 @@ export default class CellFactory {
128130
virtualized.data,
129131
virtualized.offset,
130132
!!is_focused,
131-
dropdowns
133+
dropdowns,
134+
loading_state
132135
);
133136

134137
const ops = this.getDataOpCells(

src/dash-table/derived/cell/contents.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
IViewportOffset,
1212
IColumn,
1313
Presentation,
14-
Columns
14+
Columns,
15+
ILoadingState
1516
} from 'dash-table/components/Table/props';
1617
import CellInput from 'dash-table/components/CellInput';
1718
import derivedCellEventHandlerProps, { Handler } from 'dash-table/derived/cell/eventHandlerProps';
@@ -35,15 +36,16 @@ function getCellType(
3536
active: boolean,
3637
editable: boolean,
3738
dropdown: IDropdownValue[] | undefined,
38-
presentation: Presentation | undefined
39+
presentation: Presentation | undefined,
40+
is_loading: boolean
3941
): CellType {
4042
switch (presentation) {
4143
case Presentation.Input:
42-
return (!active || !editable) ? CellType.Label : CellType.Input;
44+
return (!active || !editable || is_loading) ? CellType.Label : CellType.Input;
4345
case Presentation.Dropdown:
4446
return (!dropdown || !editable) ? CellType.DropdownLabel : CellType.Dropdown;
4547
default:
46-
return (!active || !editable) ? CellType.Label : CellType.Input;
48+
return (!active || !editable || is_loading) ? CellType.Label : CellType.Input;
4749
}
4850
}
4951

@@ -62,7 +64,8 @@ class Contents {
6264
data: Data,
6365
_offset: IViewportOffset,
6466
isFocused: boolean,
65-
dropdowns: (IDropdown | undefined)[][]
67+
dropdowns: (IDropdown | undefined)[][],
68+
loading_state: ILoadingState | undefined
6669
): JSX.Element[][] => {
6770
const formatters = R.map(getFormatter, columns);
6871

@@ -76,7 +79,8 @@ class Contents {
7679
columnIndex,
7780
rowIndex,
7881
datum,
79-
formatters
82+
formatters,
83+
loading_state
8084
), columns), data);
8185
});
8286

@@ -87,7 +91,8 @@ class Contents {
8791
data: Data,
8892
offset: IViewportOffset,
8993
isFocused: boolean,
90-
dropdowns: (IDropdown | undefined)[][]
94+
dropdowns: (IDropdown | undefined)[][],
95+
loading_state: ILoadingState | undefined
9196
): JSX.Element[][] => {
9297
if (!activeCell) {
9398
return contents;
@@ -112,20 +117,21 @@ class Contents {
112117
jActive,
113118
iActive,
114119
data[i],
115-
formatters
120+
formatters,
121+
loading_state
116122
);
117123

118124
return contents;
119125
});
120126

121-
private getContent(active: boolean, isFocused: boolean, column: IColumn, dropdown: IDropdown | undefined, columnIndex: number, rowIndex: number, datum: any, formatters: ((value: any) => any)[]) {
127+
private getContent(active: boolean, isFocused: boolean, column: IColumn, dropdown: IDropdown | undefined, columnIndex: number, rowIndex: number, datum: any, formatters: ((value: any) => any)[], loading_state: ILoadingState | undefined) {
122128
const className = [
123129
...(active ? ['input-active'] : []),
124130
isFocused ? 'focused' : 'unfocused',
125131
'dash-cell-value'
126132
].join(' ');
127133

128-
const cellType = getCellType(active, column.editable, dropdown && dropdown.options, column.presentation);
134+
const cellType = getCellType(active, column.editable, dropdown && dropdown.options, column.presentation, loading_state && loading_state.is_loading ? true : false);
129135

130136
switch (cellType) {
131137
case CellType.Dropdown:

0 commit comments

Comments
 (0)