mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
🔧 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
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:
parent
8907bd5d7c
commit
3dd827e9d2
1 changed files with 7 additions and 2 deletions
|
|
@ -134,8 +134,13 @@ function Avatar() {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const openFileDialog = () => {
|
const openFileDialog = useCallback(() => {
|
||||||
fileInputRef.current?.click();
|
fileInputRef.current?.click();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleSelectFileClick = (event: React.MouseEvent) => {
|
||||||
|
event.stopPropagation();
|
||||||
|
openFileDialog();
|
||||||
};
|
};
|
||||||
|
|
||||||
const resetImage = useCallback(() => {
|
const resetImage = useCallback(() => {
|
||||||
|
|
@ -341,7 +346,7 @@ function Avatar() {
|
||||||
: '2MB',
|
: '2MB',
|
||||||
})}
|
})}
|
||||||
</p>
|
</p>
|
||||||
<Button type="button" variant="secondary" onClick={openFileDialog}>
|
<Button type="button" variant="secondary" onClick={handleSelectFileClick}>
|
||||||
{localize('com_ui_select_file')}
|
{localize('com_ui_select_file')}
|
||||||
</Button>
|
</Button>
|
||||||
<input
|
<input
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue