From 86185886c1fa07e943b5b7828fab0009cca12b38 Mon Sep 17 00:00:00 2001 From: Oleksandr Soloviov Date: Mon, 15 Jun 2026 16:15:52 +0200 Subject: [PATCH 1/3] Ability to customize DummyInput #6099 --- docs/examples/CustomDummyInput.tsx | 31 ++++++ docs/examples/index.tsx | 1 + docs/pages/advanced/index.tsx | 11 +++ docs/pages/components/index.tsx | 12 +++ packages/react-select/src/Select.tsx | 5 +- .../src/__tests__/Select.test.tsx | 16 ++++ .../src/components/DummyInput.tsx | 94 +++++++++++++++++++ packages/react-select/src/components/index.ts | 3 + packages/react-select/src/index.ts | 1 + .../react-select/src/internal/DummyInput.tsx | 51 ---------- packages/react-select/src/internal/index.ts | 1 - packages/react-select/src/styles.ts | 3 + 12 files changed, 175 insertions(+), 54 deletions(-) create mode 100644 docs/examples/CustomDummyInput.tsx create mode 100644 packages/react-select/src/components/DummyInput.tsx delete mode 100644 packages/react-select/src/internal/DummyInput.tsx diff --git a/docs/examples/CustomDummyInput.tsx b/docs/examples/CustomDummyInput.tsx new file mode 100644 index 0000000000..a2a51ed98c --- /dev/null +++ b/docs/examples/CustomDummyInput.tsx @@ -0,0 +1,31 @@ +import React from 'react'; +import Select, { components, DummyInputProps } from 'react-select'; +import { StateOption, stateOptions } from '../data'; + +const DummyInput = (props: DummyInputProps) => { + return ( +
+ Custom Dummy Input + +
+ ); +}; + +export default () => ( + + ); + + expect( + container.querySelector('input.react-select__dummy-input') + ).not.toBeInTheDocument(); + expect(container.querySelector('.my-dummy-input-component')).toBeInTheDocument(); +}); + test('render custom Menu Component', () => { const MenuComponent = () =>
; let { container } = render( diff --git a/packages/react-select/src/components/DummyInput.tsx b/packages/react-select/src/components/DummyInput.tsx new file mode 100644 index 0000000000..635471a780 --- /dev/null +++ b/packages/react-select/src/components/DummyInput.tsx @@ -0,0 +1,94 @@ +/** @jsx jsx */ +import { InputHTMLAttributes, Ref } from 'react'; +import { jsx } from '@emotion/react'; + +import { + CommonPropsAndClassName, + CSSObjectWithLabel, + GroupBase, +} from '../types'; +import { cleanCommonProps, removeProps } from '../utils'; + +export interface DummyInputProps< + Option = unknown, + IsMulti extends boolean = boolean, + Group extends GroupBase
); @@ -28,4 +30,3 @@ export default () => ( placeholder="Select an option" /> ); - diff --git a/packages/react-select/src/__tests__/Select.test.tsx b/packages/react-select/src/__tests__/Select.test.tsx index 1ba31b9da1..dbb8e5085f 100644 --- a/packages/react-select/src/__tests__/Select.test.tsx +++ b/packages/react-select/src/__tests__/Select.test.tsx @@ -2893,7 +2893,9 @@ test('render custom Input Component', () => { }); test('render custom DummyInput Component', () => { - const DummyInputComponent = () =>
; + const DummyInputComponent = () => ( +
+ ); let { container } = render(