Skip to content

Commit ccba187

Browse files
authored
Remove timestamp props (#1082)
1 parent 44b4004 commit ccba187

File tree

13 files changed

+36
-238
lines changed

13 files changed

+36
-238
lines changed

src/components/badge/Badge.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,12 @@ const Badge = props => {
2020
text_color,
2121
color = 'secondary',
2222
n_clicks = 0,
23-
n_clicks_timestamp = -1,
2423
...otherProps
2524
} = props;
2625

2726
const incrementClicks = () => {
2827
if (setProps) {
29-
setProps({
30-
n_clicks: n_clicks + 1,
31-
n_clicks_timestamp: Date.now()
32-
});
28+
setProps({n_clicks: n_clicks + 1});
3329
}
3430
};
3531
const isBootstrapColor = bootstrapColors.has(color);
@@ -156,13 +152,6 @@ Badge.propTypes = {
156152
*/
157153
n_clicks: PropTypes.number,
158154

159-
/**
160-
* An integer that represents the time (in ms since 1970)
161-
* at which n_clicks changed. This can be used to tell
162-
* which button was changed most recently.
163-
*/
164-
n_clicks_timestamp: PropTypes.number,
165-
166155
/**
167156
* Target attribute to pass on to the link. Only applies to external links.
168157
*/

src/components/button/Button.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import {omit} from 'ramda';
43
import RBButton from 'react-bootstrap/Button';
54
import Link from '../../private/Link';
65

@@ -34,10 +33,7 @@ const Button = ({
3433
}) => {
3534
const incrementClicks = () => {
3635
if (!disabled && setProps) {
37-
setProps({
38-
n_clicks: n_clicks + 1,
39-
n_clicks_timestamp: Date.now()
40-
});
36+
setProps({n_clicks: n_clicks + 1});
4137
}
4238
};
4339
const useLink = href && !disabled;
@@ -61,7 +57,7 @@ const Button = ({
6157
value={useLink ? undefined : value}
6258
className={class_name || className}
6359
rel={useLink ? rel : undefined}
64-
{...omit(['n_clicks_timestamp'], otherProps)}
60+
{...otherProps}
6561
data-dash-is-loading={
6662
(loading_state && loading_state.is_loading) || undefined
6763
}
@@ -129,16 +125,6 @@ Button.propTypes = {
129125
*/
130126
n_clicks: PropTypes.number,
131127

132-
/**
133-
* Use of *_timestamp props has been deprecated in Dash in favour of dash.callback_context.
134-
* See "How do I determine which Input has changed?" in the Dash FAQs https://dash.plot.ly/faqs.
135-
*
136-
* An integer that represents the time (in ms since 1970)
137-
* at which n_clicks changed. This can be used to tell
138-
* which button was changed most recently.
139-
*/
140-
n_clicks_timestamp: PropTypes.number,
141-
142128
/**
143129
* Whether button is in active state. Default: False.
144130
*/

src/components/card/CardLink.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ const CardLink = ({
1919
}) => {
2020
const incrementClicks = () => {
2121
if (!disabled && setProps) {
22-
setProps({
23-
n_clicks: n_clicks + 1,
24-
n_clicks_timestamp: Date.now()
25-
});
22+
setProps({n_clicks: n_clicks + 1});
2623
}
2724
};
2825

@@ -100,13 +97,6 @@ CardLink.propTypes = {
10097
*/
10198
n_clicks: PropTypes.number,
10299

103-
/**
104-
* An integer that represents the time (in ms since 1970)
105-
* at which n_clicks changed. This can be used to tell
106-
* which button was changed most recently.
107-
*/
108-
n_clicks_timestamp: PropTypes.number,
109-
110100
/**
111101
* Object that holds the loading state object coming from dash-renderer
112102
*/

src/components/dropdownmenu/DropdownMenuItem.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,14 @@ const DropdownMenuItem = ({
2121
header,
2222
divider,
2323
n_clicks = 0,
24-
n_clicks_timestamp = -1,
2524
toggle = true,
2625
...otherProps
2726
}) => {
2827
const context = useContext(DropdownMenuContext);
2928

3029
const handleClick = e => {
3130
if (!disabled && setProps) {
32-
setProps({
33-
n_clicks: n_clicks + 1,
34-
n_clicks_timestamp: Date.now()
35-
});
31+
setProps({n_clicks: n_clicks + 1});
3632
}
3733
if (toggle && context.isOpen) {
3834
context.toggle(e);
@@ -150,13 +146,6 @@ DropdownMenuItem.propTypes = {
150146
*/
151147
n_clicks: PropTypes.number,
152148

153-
/**
154-
* An integer that represents the time (in ms since 1970)
155-
* at which n_clicks changed. This can be used to tell
156-
* which button was changed most recently.
157-
*/
158-
n_clicks_timestamp: PropTypes.number,
159-
160149
/**
161150
* Object that holds the loading state object coming from dash-renderer
162151
*/

src/components/form/Form.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import {omit} from 'ramda';
43
import RBForm from 'react-bootstrap/Form';
54

65
/**
@@ -15,7 +14,6 @@ const Form = ({
1514
class_name,
1615
prevent_default_on_submit = true,
1716
n_submit = 0,
18-
n_submit_timestamp = -1,
1917
...otherProps
2018
}) => {
2119
return (
@@ -25,10 +23,7 @@ const Form = ({
2523
e.preventDefault();
2624
}
2725
if (setProps) {
28-
setProps({
29-
n_submit: n_submit + 1,
30-
n_submit_timestamp: Date.now()
31-
});
26+
setProps({n_submit: n_submit + 1});
3227
}
3328
}}
3429
className={class_name || className}
@@ -95,11 +90,6 @@ Form.propTypes = {
9590
*/
9691
n_submit: PropTypes.number,
9792

98-
/**
99-
* Last time that `Enter` was pressed.
100-
*/
101-
n_submit_timestamp: PropTypes.number,
102-
10393
/**
10494
* The form calls preventDefault on submit events. If you want form data to
10595
* be posted to the endpoint specified by `action` on submit events, set

src/components/input/Input.js

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,7 @@ const Input = ({
116116

117117
const onBlur = () => {
118118
if (setProps) {
119-
const payload = {
120-
n_blur: n_blur + 1,
121-
n_blur_timestamp: Date.now()
122-
};
119+
const payload = {n_blur: n_blur + 1};
123120
if (debounce === true) {
124121
// numeric debounce here has no effect, we only care about boolean debounce
125122
onEvent(payload);
@@ -131,10 +128,7 @@ const Input = ({
131128

132129
const onKeyUp = e => {
133130
if (setProps && e.key === 'Enter') {
134-
const payload = {
135-
n_submit: n_submit + 1,
136-
n_submit_timestamp: Date.now()
137-
};
131+
const payload = {n_submit: n_submit + 1};
138132
if (debounce === true) {
139133
// numeric debounce here has no effect, we only care about boolean debounce
140134
onEvent(payload);
@@ -153,13 +147,7 @@ const Input = ({
153147
onBlur={onBlur}
154148
onKeyUp={onKeyUp}
155149
{...omit(
156-
[
157-
'n_blur_timestamp',
158-
'n_submit_timestamp',
159-
'persistence',
160-
'persistence_type',
161-
'persisted_props'
162-
],
150+
['persistence', 'persistence_type', 'persisted_props'],
163151
otherProps
164152
)}
165153
valid={valid ? 'true' : undefined}
@@ -585,21 +573,11 @@ Input.propTypes = {
585573
*/
586574
n_submit: PropTypes.number,
587575

588-
/**
589-
* Last time that `Enter` was pressed.
590-
*/
591-
n_submit_timestamp: PropTypes.number,
592-
593576
/**
594577
* Number of times the input lost focus.
595578
*/
596579
n_blur: PropTypes.number,
597580

598-
/**
599-
* Last time the input lost focus.
600-
*/
601-
n_blur_timestamp: PropTypes.number,
602-
603581
/**
604582
* If true, changes to input will be sent back to the Dash server
605583
* only when the enter key is pressed or when the component loses

src/components/input/Textarea.js

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,8 @@ const Textarea = ({
3434
tabIndex,
3535
tabindex,
3636
n_blur = 0,
37-
n_blur_timestamp = -1,
3837
n_submit = 0,
39-
n_submit_timestamp = -1,
4038
n_clicks = 0,
41-
n_clicks_timestamp = -1,
4239
debounce = false,
4340
value = '',
4441
submit_on_enter = true,
@@ -71,10 +68,7 @@ const Textarea = ({
7168

7269
const onBlur = e => {
7370
if (setProps) {
74-
const payload = {
75-
n_blur: n_blur + 1,
76-
n_blur_timestamp: Date.now()
77-
};
71+
const payload = {n_blur: n_blur + 1};
7872
if (debounce === true) {
7973
payload.value = e.target.value;
8074
}
@@ -85,10 +79,7 @@ const Textarea = ({
8579
const onKeyUp = e => {
8680
if (submit_on_enter && setProps && e.key === 'Enter' && !e.shiftKey) {
8781
e.preventDefault(); // don't create newline if submitting
88-
const payload = {
89-
n_submit: n_submit + 1,
90-
n_submit_timestamp: Date.now()
91-
};
82+
const payload = {n_submit: n_submit + 1};
9283
if (debounce === true) {
9384
payload.value = e.target.value;
9485
}
@@ -98,10 +89,7 @@ const Textarea = ({
9889

9990
const onClick = () => {
10091
if (setProps) {
101-
setProps({
102-
n_clicks: n_clicks + 1,
103-
n_clicks_timestamp: Date.now()
104-
});
92+
setProps({n_clicks: n_clicks + 1});
10593
}
10694
};
10795

@@ -131,13 +119,7 @@ const Textarea = ({
131119
spellCheck={spellcheck || spellCheck}
132120
tabIndex={tabindex || tabIndex}
133121
{...omit(
134-
[
135-
'n_blur_timestamp',
136-
'n_submit_timestamp',
137-
'persistence',
138-
'persistence_type',
139-
'persisted_props'
140-
],
122+
['persistence', 'persistence_type', 'persisted_props'],
141123
otherProps
142124
)}
143125
data-dash-is-loading={
@@ -410,10 +392,6 @@ Textarea.propTypes = {
410392
* Number of times the input lost focus.
411393
*/
412394
n_blur: PropTypes.number,
413-
/**
414-
* Last time the input lost focus.
415-
*/
416-
n_blur_timestamp: PropTypes.number,
417395

418396
/**
419397
* Number of times the `Enter` key was pressed while the textarea had focus. Only
@@ -422,13 +400,8 @@ Textarea.propTypes = {
422400
n_submit: PropTypes.number,
423401

424402
/**
425-
* Last time that `Enter` was pressed. Only updates if submit_on_enter is True.
426-
*/
427-
n_submit_timestamp: PropTypes.number,
428-
429-
/**
430-
* Whether or not the form should increment the n_submit and n_submit_timestamp props
431-
* when enter key is pressed. If True, use shift + enter to create a newline. Default: True
403+
* Whether or not the form should increment the n_submit prop when enter key is
404+
* pressed. If True, use shift + enter to create a newline. Default: True
432405
*/
433406
submit_on_enter: PropTypes.bool,
434407

@@ -438,13 +411,6 @@ Textarea.propTypes = {
438411
*/
439412
n_clicks: PropTypes.number,
440413

441-
/**
442-
* An integer that represents the time (in ms since 1970)
443-
* at which n_clicks changed. This can be used to tell
444-
* which button was changed most recently.
445-
*/
446-
n_clicks_timestamp: PropTypes.number,
447-
448414
/**
449415
* If true, changes to input will be sent back to the Dash server only on enter or
450416
* when losing focus. If it's false, it will sent the value back on every change.

0 commit comments

Comments
 (0)