fix issue,

This commit is contained in:
Víctor Losada Hernández
2026-10-30 00:16:07 +01:00
parent 6d8418880d
commit 89667f38b5
2 changed files with 16 additions and 6 deletions
+15 -6
View File
@@ -1,4 +1,4 @@
import React, { useState, useEffect, useRef } from 'react';
import React, { useState, useEffect, useRef, useCallback } from 'react';
import _ from 'lodash';
import './combobox.less';
@@ -16,6 +16,7 @@ const Combobox = ({
},
valuePatterns = /.+/,
options = [],
keepValueOnClose = false,
...props
})=>{
const dropdownRef = useRef(null);
@@ -30,15 +31,23 @@ const Combobox = ({
}
}, []);
const handleClickOutside = (e)=>{
const handleClickOutside = useCallback((e)=>{
// Close dropdown when clicked outside
if(!dropdownRef.current?.contains(e.target)) handleDropdown(false);
};
if(!dropdownRef.current?.contains(e.target)) {
handleDropdown(false);
}
}, []);
const handleDropdown = (show)=>{
setValue(show ? '' : defaultValue);
if(show) {
if(autoSuggest.clearAutoSuggestOnClick) {
setValue('');
}
} else if(!keepValueOnClose) {
setValue(defaultValue);
}
setShowDropdown(show);
setInputFocused(autoSuggest.clearAutoSuggestOnClick ? show : false);
setInputFocused(autoSuggest.clearAutoSuggestOnClick && show);
};
const handleInput = (e)=>{
@@ -262,6 +262,7 @@ const MetadataEditor = ({
id='combobox-language'
className='language-dropdown'
defaultValue={metadata.lang || ''}
keepValueOnClose={true}
placeholder='en'
onSelect={(value)=>handleLanguage(value)}
onEntry={(e)=>{