Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: dataset search-input compostion can't work in chrome (#11907)

zhu-an6ded06c6d966
diff --git a/web/app/components/base/search-input/index.tsx b/web/app/components/base/search-input/index.tsx
index 89345fbe328..556a7bdf492 100644
--- a/web/app/components/base/search-input/index.tsx
+++ b/web/app/components/base/search-input/index.tsx
@@ -23,6 +23,7 @@ const SearchInput: FC<SearchInputProps> = ({
const { t } = useTranslation()
const [focus, setFocus] = useState<boolean>(false)
const isComposing = useRef<boolean>(false)
+ const [internalValue, setInternalValue] = useState<string>(value)
return (
<div className={cn(
@@ -45,16 +46,18 @@ const SearchInput: FC<SearchInputProps> = ({
white && '!bg-white hover:!bg-white group-hover:!bg-white placeholder:!text-gray-400',
)}
placeholder={placeholder || t('common.operation.search')!}
- value={value}
+ value={internalValue}
onChange={(e) => {
+ setInternalValue(e.target.value)
if (!isComposing.current)
onChange(e.target.value)
}}
onCompositionStart={() => {
isComposing.current = true
}}
- onCompositionEnd={() => {
+ onCompositionEnd={(e) => {
isComposing.current = false
+ onChange(e.data)
}}
onFocus={() => setFocus(true)}
onBlur={() => setFocus(false)}
@@ -63,7 +66,10 @@ const SearchInput: FC<SearchInputProps> = ({
{value && (
<div
className='shrink-0 flex items-center justify-center w-4 h-4 cursor-pointer group/clear'
- onClick={() => onChange('')}
+ onClick={() => {
+ onChange('')
+ setInternalValue('')
+ }}
>
<XCircle className='w-3.5 h-3.5 text-gray-400 group-hover/clear:text-gray-600' />
</div>