Skip to content

Commit 0f69012

Browse files
authored
fix: missing compitable (#1170)
1 parent 64f9dbf commit 0f69012

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/SelectInput/Input.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>((props, ref) => {
4343
onInputBlur,
4444
autoFocus,
4545
tokenWithEnter,
46+
placeholder,
4647
components: { input: InputComponent = 'input' },
4748
} = useSelectInputContext();
4849
const { id, classNames, styles, open, activeDescendantId, role, disabled } = useBaseProps() || {};
@@ -190,7 +191,11 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>((props, ref) => {
190191
const existingProps: any = InputComponent.props || {};
191192

192193
// Start with shared props as base
193-
const mergedProps = { ...sharedInputProps, ...existingProps };
194+
const mergedProps = {
195+
placeholder: props.placeholder || placeholder,
196+
...sharedInputProps,
197+
...existingProps,
198+
};
194199

195200
// Batch update function calls
196201
Object.keys(existingProps).forEach((key) => {

tests/components.test.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { render } from '@testing-library/react';
2+
import React from 'react';
3+
import Select from '../src';
4+
import { injectRunAllTimers } from './utils/common';
5+
6+
describe('Select.Components', () => {
7+
injectRunAllTimers(jest);
8+
9+
beforeEach(() => {
10+
jest.useFakeTimers();
11+
});
12+
13+
afterEach(() => {
14+
jest.clearAllTimers();
15+
jest.useRealTimers();
16+
});
17+
18+
it('should pass placeholder to custom input', () => {
19+
const { container } = render(
20+
<Select mode="combobox" getInputElement={() => <textarea />} placeholder="test" />,
21+
);
22+
23+
expect(container.querySelector('textarea')?.getAttribute('placeholder')).toBe('test');
24+
});
25+
});

0 commit comments

Comments
 (0)