Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ export const SettingsSection = () => {
key={selectedInstance.id}
placeholder={placeholder}
value={localValue.value}
onChange={(event) => localValue.set(event.target.value.trim())}
onBlur={localValue.save}
onChange={(event) => localValue.set(event.target.value)}
onBlur={(event) =>
localValue.finalSave(
Copy link
Member

@kof kof Feb 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TrySound maybe take over and see what's the best solution, because we are not getting anywhere

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to me it seemed like the initial version, where he was setting the trimmed value on blur and then calling save was a good call

(event.target as HTMLInputElement).value.trim()
)
}
/>
</HorizontalLayout>
</Row>
Expand Down
7 changes: 7 additions & 0 deletions apps/builder/app/builder/features/settings-panel/shared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ export const useLocalValue = <Type,>(
}
};

const finalSave = (value: Type) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't sound like great addition to the api, semantics with this are messy.

localValueRef.current = value;
setRefresh((refresh) => refresh + 1);
save();
};

const saveDebounced = useDebouncedCallback(save, 500);

const setLocalValue = (value: Type) => {
Expand Down Expand Up @@ -224,6 +230,7 @@ export const useLocalValue = <Type,>(
* Should be called on onBlur or similar event
*/
save,
finalSave,
};
};

Expand Down
Loading