How to Keep Clear Button Visible in React DropdownList on Lose Focus?
This article provides a solution for ensuring that the clear button in the React Dropdown List component remains visible even after the component loses focus. By default, the clear button is only visible when the component is focused, but with a simple modification, it can be made static.
Making the Clear Button Static
To achieve the desired functionality, you can use a custom CSS class in conjunction with the showClearButton
property. Below is a code snippet demonstrating how to implement this:
<DropDownListComponent
id="games"
dataSource={sportsData}
fields={fields}
placeholder="Select a game"
value={value}
popupHeight="220px"
showClearButton={true}
cssClass="e-static-clear"
/>
Setting showClearButton
to true enables the clear button, and applying the e-static-clear
class ensures that the clear button remains visible even when the DropdownList component is not focused.
Sample
You can review and test the implementation in the following sample: StackBlitz Example.
Conclusion
I hope you enjoyed about how to keep clear button visible in React Dropdown List on lose focus.
You can refer to our React Dropdown List feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our React Dropdown List example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!