Skip to content
Open
Changes from 2 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,11 @@ 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.set((event.target as HTMLInputElement).value.trim());
localValue.save;
Copy link
Member

Choose a reason for hiding this comment

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

save is not invoked

Copy link
Member

Choose a reason for hiding this comment

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

I would do trimming inside of useLocalValue callback instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would do trimming inside of useLocalValue callback instead

I tried this initially but the text was getting trimmed after a few milliseconds when we are typing.

screenrecord-2025-02-19_21-26-27.mp4

we could use something like the following
export a new function inside the useLocalvalue hook.

  const finalSave = (value: Type) => {
    localValueRef.current = value;
    setRefresh((refresh) => refresh + 1);
    save();
  };

then run it on the onBlur event as follows, which would trim out the white space and also call the save function to sync the value on the server. what do you think @TrySound

<InputField
          id={id}
          /* Key is required, otherwise when label is undefined, previous value stayed */
          key={selectedInstance.id}
          placeholder={placeholder}
          value={localValue.value}
          onChange={(event) => localValue.set(event.target.value)}
          onBlur={(event) =>
            localValue.finalSave(
              (event.target as HTMLInputElement).value.trim()
            )
          }
        />

}}
/>
</HorizontalLayout>
</Row>
Expand Down
Loading