From a2b393687860e507b2482faa2bc7493c8b0f9e1d Mon Sep 17 00:00:00 2001 From: Julian Nymark Date: Thu, 19 Dec 2024 14:23:39 +0100 Subject: [PATCH] Textarea: resize immediately upon receiving resize event (#3463) * change: add story to demonstrate buggy textarea behaviour inside modal * use lodash debounce with our own default value for wait * Revert "use lodash debounce with our own default value for wait" This reverts commit 7638297765de68b2155624fe0663fea868a87136. * change: add leading to debounce + use it in TextareaAutoSize * changeset * changeset + co-author Co-authored-by: Halvor Haugan --------- Co-authored-by: Halvor Haugan --- .changeset/cool-trains-care.md | 5 ++++ .../src/form/textarea/textarea.stories.tsx | 21 +++++++++++++++ .../core/react/src/util/TextareaAutoSize.tsx | 26 +++++++++++-------- @navikt/core/react/src/util/debounce.ts | 14 +++++++--- 4 files changed, 52 insertions(+), 14 deletions(-) create mode 100644 .changeset/cool-trains-care.md diff --git a/.changeset/cool-trains-care.md b/.changeset/cool-trains-care.md new file mode 100644 index 0000000000..df0e28f46b --- /dev/null +++ b/.changeset/cool-trains-care.md @@ -0,0 +1,5 @@ +--- +"@navikt/ds-react": patch +--- + +Textarea: resize immediately upon receiving resize event (eg. inside modal opening). diff --git a/@navikt/core/react/src/form/textarea/textarea.stories.tsx b/@navikt/core/react/src/form/textarea/textarea.stories.tsx index 13772cdb50..70222517c4 100644 --- a/@navikt/core/react/src/form/textarea/textarea.stories.tsx +++ b/@navikt/core/react/src/form/textarea/textarea.stories.tsx @@ -226,6 +226,27 @@ AutoScrollbar.argTypes = { minRows: { type: "number" }, }; +export const InsideModal: StoryFn = () => { + const ref = React.useRef(null); + + return ( + <> + + + + +