Skip to content

Commit 26a86a3

Browse files
feat: TypeaheadVariableDropdown select entire text on click (#3066)
1 parent d3b490d commit 26a86a3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/variables/components/TypeAheadVariableDropdown.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Libraries
2-
import React, {PureComponent} from 'react'
2+
import React, {PureComponent, ChangeEvent} from 'react'
33
import {connect, ConnectedProps} from 'react-redux'
44
import classnames from 'classnames'
55

@@ -260,6 +260,12 @@ class TypeAheadVariableDropdown extends PureComponent<Props, MyState> {
260260

261261
const widthStyle = this.getWidth(placeHolderText)
262262

263+
const selectAllTextInInput = (event?: ChangeEvent<HTMLInputElement>) => {
264+
if (event) {
265+
event.target.select()
266+
}
267+
}
268+
263269
const getInnerComponent = () => {
264270
if (status === RemoteDataState.Loading || this.noValuesPresent()) {
265271
return placeHolderText
@@ -271,6 +277,7 @@ class TypeAheadVariableDropdown extends PureComponent<Props, MyState> {
271277
value={typedValue}
272278
onKeyDown={this.maybeSelectNextItem}
273279
testID={`variable-dropdown-input-typeAhead--${name}`}
280+
onFocus={selectAllTextInInput}
274281
/>
275282
)
276283
}

0 commit comments

Comments
 (0)