-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Use extra React state to track temporary Zarr URL #48
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
onChange={(e) => setDataUrl(new URL(e.target.value))} | ||
label="Zarr group track data URL" | ||
hideLabel={true} | ||
placeholder="Zarr group track data URL" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably shouldn't have a visible label and a placeholder unless they contain different information. I slightly prefer the placeholder because it saves space, but no strong preference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if there is a design principle we can refer to here. The name "placeholder" to me implies it should be some example text, rather than a label or instruction. Otherwise I agree I would lean toward using the placeholder and removing the label to save space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't find any recommendations from Material: https://m3.material.io/components/text-fields/overview
Looks like the placeholder isn't recommended there - instead a label underneath should be used to explain what this is.
I've seen a placeholder used for instructions or for an example.
I'll just leave it alone in this PR though and we can poke design later to see what their recommendations area.
I looked in the mui docs and found diff --git a/src/scene.tsx b/src/scene.tsx
index 57e02e0..28e2811 100644
--- a/src/scene.tsx
+++ b/src/scene.tsx
@@ -22,7 +22,6 @@ export default function Scene(props: SceneProps) {
const [trackManager, setTrackManager] = useState<TrackManager>();
const [dataUrl, setDataUrl] = useState(DEFAULT_ZARR_URL);
- const [tempDataUrl, setTempDataUrl] = useState(DEFAULT_ZARR_URL.toString());
const [numTimes, setNumTimes] = useState(0);
const [curTime, setCurTime] = useState(0);
const [autoRotate, setAutoRotate] = useState(false);
@@ -175,19 +174,15 @@ export default function Scene(props: SceneProps) {
label="Zarr group track data URL"
hideLabel={true}
placeholder="Zarr group track data URL"
- value={tempDataUrl}
- onChange={(e) => setTempDataUrl(e.target.value)}
- onKeyUp={(e) => {
- if (e.key === "Enter") setDataUrl(new URL(tempDataUrl));
- }}
- onBlur={() => setDataUrl(new URL(tempDataUrl))}
+ onChange={(e) => setDataUrl(new URL(e.target.value))}
fullWidth={true}
+ defaultValue={DEFAULT_ZARR_URL.toString()}
intent={trackManager ? "default" : "error"}
/>
<InputSlider
id="time-frame-slider" |
Good find, but this just behaves the same as |
Hmm, maybe we're thinking of different problems in that case. I was thinking updates/re-render with What I was trying to report in #46 is (on |
Agreed there are two different problems here. I'm down to use And then think about how we actually want to track every change or have some way to submit that (e.g. using enter). As this PR mostly does the latter, I'll just close it and reopen a different one for the simple fix. |
This is one way to have the text input field reflect the value being currently edited, though it feels oh so wrong.
Maybe a better approach is to load the track manager and set it on the enter key or blur/lose-focus event?
Closes #46