mirror of https://github.com/grafana/grafana
Select: Add data-testid to Input (#87105)
* Select: Add custom input component * Forward data-testid * Add input selector * Props checkpull/86994/head^2
parent
ec6f59a678
commit
7f1b2ef205
@ -0,0 +1,15 @@ |
|||||||
|
import React from 'react'; |
||||||
|
import { components, InputProps } from 'react-select'; |
||||||
|
|
||||||
|
/** |
||||||
|
* Custom input component for react-select to add data-testid attribute |
||||||
|
*/ |
||||||
|
export const CustomInput = (props: InputProps) => { |
||||||
|
let testId; |
||||||
|
|
||||||
|
if ('data-testid' in props.selectProps && props.selectProps['data-testid']) { |
||||||
|
testId = props.selectProps['data-testid'] + '-input'; |
||||||
|
} |
||||||
|
|
||||||
|
return <components.Input {...props} data-testid={testId} />; |
||||||
|
}; |
||||||
Loading…
Reference in new issue