From 6fcf81b320a3027852c5e5e5a8c84430c435b478 Mon Sep 17 00:00:00 2001 From: yellowsink Date: Sat, 10 Aug 2024 12:04:29 +0100 Subject: [PATCH] only set textbox if necessary (fix UWU-110), fix test --- packages/shelter-ui-test/src/index.tsx | 5 +- packages/shelter-ui/src/textbox.tsx | 17 +- pnpm-lock.yaml | 8985 +++++++++++++----------- 3 files changed, 4945 insertions(+), 4062 deletions(-) diff --git a/packages/shelter-ui-test/src/index.tsx b/packages/shelter-ui-test/src/index.tsx index a8c7f38..b4b3a4b 100644 --- a/packages/shelter-ui-test/src/index.tsx +++ b/packages/shelter-ui-test/src/index.tsx @@ -1,14 +1,15 @@ /* @refresh reload */ import { render } from "solid-js/web"; -import { initToasts } from "@uwu/shelter-ui"; +import { initToasts, injectInternalStyles } from "@uwu/shelter-ui"; -import "shelter-ui/compat.css"; +import "@uwu/shelter-ui/compat.css"; import "./index.css"; import App from "./App"; const root = document.getElementById("root"); initToasts(document.body); +injectInternalStyles(); render(() => , root!); diff --git a/packages/shelter-ui/src/textbox.tsx b/packages/shelter-ui/src/textbox.tsx index 3eab08c..f1c6d74 100644 --- a/packages/shelter-ui/src/textbox.tsx +++ b/packages/shelter-ui/src/textbox.tsx @@ -1,4 +1,4 @@ -import { Component } from "solid-js"; +import { Component, createEffect } from "solid-js"; import { css, classes } from "./textbox.tsx.scss"; import { focusring } from "./focusring"; import { ensureInternalStyle } from "./internalstyles"; @@ -14,12 +14,18 @@ export const TextBox: Component<{ }> = (props) => { ensureInternalStyle(css); + let r: HTMLInputElement; + createEffect(() => { + // only set value if it changed, to avoid unnecessary resets of scroll position from doing value = value + if (props.value !== r?.value && r) r.value = props.value; + }); + return ( = (props) => { ensureInternalStyle(css); + let r: HTMLTextAreaElement; + createEffect(() => { + if (props.value !== r?.value && r) r.value = props.value; + }); + return (