MCPcopy Index your code
hub / github.com/plotly/dash / IsolatedInput

Class IsolatedInput

components/dash-table/src/core/components/IsolatedInput/index.tsx:31–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29type PropsWithDefaults = IProps & IDefaultProps;
30
31export default class IsolatedInput extends PureComponent<IProps, IState> {
32 public static readonly defaultProps = {
33 stopPropagation: false,
34 updateOnEnter: true,
35 updateOnBlur: true,
36 updateOnSubmit: true
37 };
38
39 private get propsWithDefaults() {
40 return this.props as PropsWithDefaults;
41 }
42
43 UNSAFE_componentWillReceiveProps(nextProps: IProps) {
44 const {value} = this.props;
45 const {value: nextValue} = nextProps;
46
47 if (value !== nextValue) {
48 this.setState({
49 value: nextValue
50 });
51 }
52 }
53
54 constructor(props: PropsWithDefaults) {
55 super(props);
56
57 this.state = {
58 value: props.value
59 };
60 }
61
62 handleKeyDown = (e: React.KeyboardEvent) => {
63 const {stopPropagation, updateOnEnter} = this.propsWithDefaults;
64
65 if (stopPropagation) {
66 e.stopPropagation();
67 }
68
69 if (updateOnEnter && e.keyCode === KEY_CODES.ENTER) {
70 this.submit();
71 }
72 };
73
74 handleChange = (ev: any) => {
75 this.setState({
76 value: ev.target.value
77 });
78 };
79
80 submit = () =>
81 this.state.value !== this.props.value &&
82 this.props.submit(this.state.value);
83
84 render() {
85 const {onCopy, onPaste, placeholder, updateOnBlur, updateOnSubmit} =
86 this.propsWithDefaults;
87
88 const props = {

Callers

nothing calls this directly

Calls 1

setStateMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…