Skip to content

Commit 872e8a7

Browse files
committed
add the mode prop for manual override of loading state
1 parent d87be76 commit 872e8a7

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

components/dash-core-components/src/components/Loading.react.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const getSpinner = spinnerType =>
2323
const Loading = ({
2424
children,
2525
loading_state,
26+
mode,
2627
color,
2728
className,
2829
style,
@@ -77,6 +78,11 @@ const Loading = ({
7778

7879
// delay_hide and delay_show is from dash-bootstrap-components dbc.Spinner
7980
useEffect(() => {
81+
if (mode === 'on' || mode === 'off') {
82+
setShowSpinner(mode === 'on');
83+
return;
84+
}
85+
8086
if (loading_state) {
8187
if (loading_state.is_loading) {
8288
// if component is currently loading and there's a dismiss timer active
@@ -108,7 +114,7 @@ const Loading = ({
108114
}
109115
}
110116
}
111-
}, [delay_hide, delay_show, loading_state]);
117+
}, [delay_hide, delay_show, loading_state, mode]);
112118

113119
const Spinner = showSpinner && getSpinner(spinnerType);
114120

@@ -147,6 +153,7 @@ Loading.defaultProps = {
147153
delay_show: 0,
148154
delay_hide: 0,
149155
show_initially: true,
156+
mode: 'auto',
150157
};
151158

152159
Loading.propTypes = {
@@ -230,6 +237,11 @@ Loading.propTypes = {
230237
component_name: PropTypes.string,
231238
}),
232239

240+
/**
241+
* Setting mode to "on" or "off" will override the loading state coming from dash-renderer
242+
*/
243+
mode: PropTypes.oneOf(['auto', 'on', 'off']),
244+
233245
/**
234246
* Add a time delay (in ms) to the spinner being removed to prevent flickering.
235247
*/

0 commit comments

Comments
 (0)