Skip to content

Commit 82c9189

Browse files
committed
Merge branch 'feat/input-ref-search-bar' of github.com:devtron-labs/devtron-fe-common-lib into feat/input-ref-search-bar
2 parents 347b268 + d6ee29c commit 82c9189

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Common/SearchBar/SearchBar.component.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ const SearchBar = ({
113113
}
114114
}
115115

116+
const inputCallbackRef: React.RefCallback<HTMLInputElement> = (node = null) => {
117+
if (inputProps.ref) {
118+
// eslint-disable-next-line no-param-reassign
119+
inputProps.ref.current = node
120+
}
121+
inputRef.current = node
122+
}
123+
116124
return (
117125
<div className={containerClassName}>
118126
<div
@@ -130,7 +138,7 @@ const SearchBar = ({
130138
} ${noBackgroundAndBorder ? 'dc__no-background' : 'bc-n50'}`}
131139
onChange={handleChange}
132140
onKeyDown={handleKeyDown}
133-
ref={inputRef}
141+
ref={inputCallbackRef}
134142
/>
135143
{/* TODO: Sync with product since it should have ic-enter in case of not applied */}
136144
{showClearButton && (

src/Common/SearchBar/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export interface SearchBarProps {
3232
/**
3333
* Input props for the search input
3434
*/
35-
inputProps?: React.InputHTMLAttributes<HTMLInputElement>
35+
inputProps?: React.InputHTMLAttributes<HTMLInputElement> &
36+
Partial<Record<'ref', React.MutableRefObject<HTMLInputElement>>>
3637
/**
3738
* Class name for the container; can be used for handling width
3839
*/

0 commit comments

Comments
 (0)