@snapdragonsnursery/react-components 1.17.6 → 1.17.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snapdragonsnursery/react-components",
3
- "version": "1.17.6",
3
+ "version": "1.17.8",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -70,6 +70,7 @@ export const EmployeeSelect = ({
70
70
  const [searchTerm, setSearchTerm] = React.useState("");
71
71
  const [isOpen, setIsOpen] = React.useState(false);
72
72
  const [debouncedSearchTerm, setDebouncedSearchTerm] = React.useState("");
73
+ const searchInputRef = React.useRef(null);
73
74
 
74
75
  // Debounce search term for server-side search
75
76
  React.useEffect(() => {
@@ -83,6 +84,16 @@ export const EmployeeSelect = ({
83
84
  return () => clearTimeout(timer);
84
85
  }, [searchTerm, enableServerSearch, onSearchChange]);
85
86
 
87
+ // Maintain focus on search input when server results update
88
+ React.useEffect(() => {
89
+ if (enableServerSearch && isOpen && searchInputRef.current && document.activeElement !== searchInputRef.current) {
90
+ // Only refocus if we previously had focus (i.e., user was typing)
91
+ if (searchTerm && !isSearching) {
92
+ searchInputRef.current.focus();
93
+ }
94
+ }
95
+ }, [searchResults, enableServerSearch, isOpen, searchTerm, isSearching]);
96
+
86
97
  // Helper function to generate initials from full name
87
98
  const getInitials = (name) => {
88
99
  if (!name) return "??";
@@ -239,8 +250,9 @@ export const EmployeeSelect = ({
239
250
  <div className="relative">
240
251
  <Search className="absolute left-2 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground" />
241
252
  <input
253
+ ref={searchInputRef}
242
254
  type="text"
243
- placeholder={enableServerSearch ? "Search employees (server-side)..." : "Search employees..."}
255
+ placeholder={enableServerSearch ? "Search employees..." : "Search employees..."}
244
256
  value={searchTerm}
245
257
  onChange={(e) => setSearchTerm(e.target.value)}
246
258
  className="w-full pl-8 pr-3 py-2 text-sm border rounded-md focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 bg-background"