🔧 refactor: Update Avatar component to improve file selection handling (#10555)
Some checks are pending
Docker Dev Branch Images Build / build (Dockerfile, lc-dev, node) (push) Waiting to run
Docker Dev Branch Images Build / build (Dockerfile.multi, lc-dev-api, api-build) (push) Waiting to run
Docker Dev Images Build / build (Dockerfile, librechat-dev, node) (push) Waiting to run
Docker Dev Images Build / build (Dockerfile.multi, librechat-dev-api, api-build) (push) Waiting to run
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Waiting to run
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Blocked by required conditions

* Refactored `openFileDialog` to use `useCallback` for better performance.
* Introduced `handleSelectFileClick` to manage file selection click events, enhancing user interaction.
This commit is contained in:
Joseph Licata 2025-11-17 17:11:48 -05:00 committed by GitHub
parent 8907bd5d7c
commit 3dd827e9d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -134,8 +134,13 @@ function Avatar() {
e.preventDefault();
}, []);
const openFileDialog = () => {
const openFileDialog = useCallback(() => {
fileInputRef.current?.click();
}, []);
const handleSelectFileClick = (event: React.MouseEvent) => {
event.stopPropagation();
openFileDialog();
};
const resetImage = useCallback(() => {
@ -341,7 +346,7 @@ function Avatar() {
: '2MB',
})}
</p>
<Button type="button" variant="secondary" onClick={openFileDialog}>
<Button type="button" variant="secondary" onClick={handleSelectFileClick}>
{localize('com_ui_select_file')}
</Button>
<input