Skip to content

Commit

Permalink
fix(lld): use a debounce on memotag field
Browse files Browse the repository at this point in the history
  • Loading branch information
KVNLS committed Dec 5, 2024
1 parent 1447c15 commit 8af048e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-ravens-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ledger-live-desktop": minor
---

LLD: LIVE-15143 use a debounce on the memotag field
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import React, { useState, useEffect } from "react";
import Input, { Props as InputBaseProps } from "~/renderer/components/Input";
import { useDebounce } from "@ledgerhq/live-common//hooks/useDebounce";
import Label from "~/renderer/components/Label";
import Box from "~/renderer/components/Box";
import { useTranslation } from "react-i18next";
Expand Down Expand Up @@ -46,6 +47,13 @@ const MemoTagField = ({
tooltipText,
}: MemoTagFieldProps) => {
const { t } = useTranslation();
const [memoValue, setMemoValue] = useState(value);
const debouncedMemoValue = useDebounce(memoValue, 300);

useEffect(() => {
if (debouncedMemoValue !== value) onChange?.(debouncedMemoValue || "");
}, [debouncedMemoValue, onChange, value]);

return (
<Box flow={1}>
{showLabel && (
Expand All @@ -68,10 +76,10 @@ const MemoTagField = ({
<Flex justifyContent="end">{CaracterCountComponent && <CaracterCountComponent />}</Flex>
<Input
placeholder={placeholder ?? t("MemoTagField.placeholder")}
onChange={onChange}
onChange={setMemoValue}
warning={warning}
error={error}
value={value}
value={memoValue}
spellCheck="false"
ff="Inter"
maxMemoLength={maxMemoLength}
Expand Down

0 comments on commit 8af048e

Please sign in to comment.