mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Added debounce to background colour picker (#18052)
no issue
---
<!-- Leave the line below if you'd like GitHub Copilot to generate a
summary from your commit -->
<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at 910bfbe</samp>
Optimized theme settings component to use debounced function for
updating settings. This reduces API requests and improves UX.
This commit is contained in:
parent
dd7df1ec6c
commit
f7f0f3033e
1 changed files with 4 additions and 1 deletions
|
@ -8,6 +8,7 @@ import SettingGroupContent from '../../../../admin-x-ds/settings/SettingGroupCon
|
|||
import TextField from '../../../../admin-x-ds/global/form/TextField';
|
||||
import Toggle from '../../../../admin-x-ds/global/form/Toggle';
|
||||
import {CustomThemeSetting} from '../../../../api/customThemeSettings';
|
||||
import {debounce} from '../../../../utils/debounce';
|
||||
import {getImageUrl, useUploadImage} from '../../../../api/images';
|
||||
import {humanizeSettingKey} from '../../../../api/settings';
|
||||
|
||||
|
@ -22,6 +23,8 @@ const ThemeSetting: React.FC<{
|
|||
setSetting(imageUrl);
|
||||
};
|
||||
|
||||
const updateSettingDebounced = debounce(setSetting, 500);
|
||||
|
||||
switch (setting.type) {
|
||||
case 'text':
|
||||
return (
|
||||
|
@ -59,7 +62,7 @@ const ThemeSetting: React.FC<{
|
|||
hint={setting.description}
|
||||
title={humanizeSettingKey(setting.key)}
|
||||
value={setting.value || ''}
|
||||
onChange={value => setSetting(value)}
|
||||
onChange={value => updateSettingDebounced(value)}
|
||||
/>
|
||||
);
|
||||
case 'image':
|
||||
|
|
Loading…
Add table
Reference in a new issue