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

Class CellInput

components/dash-table/src/dash-table/components/CellInput/index.tsx:28–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26}
27
28export default class CellInput extends PureComponent<ICellProps, ICellState> {
29 textInputRef: React.RefObject<any>;
30 constructor(props: ICellProps) {
31 super(props);
32
33 this.state = {
34 value: props.value
35 };
36
37 this.textInputRef = createRef();
38 }
39
40 render() {
41 const {className, onMouseUp, onPaste, value} = this.props;
42
43 // input does not handle `null` correct (causes console error)
44 const sanitizedValue =
45 this.state.value === null ? undefined : this.state.value;
46
47 return (
48 <div className='dash-input-cell-value-container dash-cell-value-container'>
49 <div className='input-cell-value-shadow cell-value-shadow'>
50 {value}
51 </div>
52 <input
53 ref={this.textInputRef}
54 type='text'
55 className={className}
56 onBlur={this.propagateChange}
57 onChange={this.handleChange}
58 onKeyDown={this.handleKeyDown}
59 onMouseUp={onMouseUp}
60 onPaste={onPaste}
61 value={sanitizedValue}
62 />
63 </div>
64 );
65 }
66
67 propagateChange = () => {
68 if (this.state.value === this.props.value) {
69 return;
70 }
71
72 const {onChange} = this.props;
73
74 onChange(this.state.value);
75 };
76
77 handleChange = (e: any) => {
78 this.setState({value: e.target.value});
79 };
80
81 handleKeyDown = (e: KeyboardEvent) => {
82 const is_focused = this.props.focused;
83
84 if (
85 is_focused &&

Callers

nothing calls this directly

Calls 2

isNavKeyFunction · 0.90
setStateMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…