Correct way to have inputs show other data?
The goal here is to show a color input. If the input is empty then it shows the user's current color. If it's showing the user's current color, then I want it t o be able to modify the color variable. This all basically works, but what it's doing is quickly updating the variable to the user's color instead of just staying blank and falling back to the user's color. This causes a double render and makes it so that if the user's color changes, then this won't be using the new value.
Is there a better way to do this?
65 Replies
Where
updates.data.measureTemplate.color
is seeded with any current values when the form is opened (updates
is seeded with current data when opened)Do you have a repo link as well?
Not with my current changes
I am confused as to what is causing an update here
I believe it's the
data-edit
property
As I still want the input to be editable so the user can change itWhy not use svelte to do the updates?
This is being dropped directly into a Item sheet in foundry
Not using svelte (for the update) because I'd rather have it within the Item sheet so it's more integrated
You are already
bind:value
itRight, that's for the case when there is already a value
Specifically the question is how to handle the else block where I want the input to be editable when there is no value, but behave as if the value is
currentUserColor
What do you mean "behave", because from what I am seeing you are just inputting the
currentUserColor
into the input and that may or may not be triggering the update through data-edit
Yes, this isn't working as I want it and I don't know the correct way to do it, hence the questi on 🙃
If you want the color to show up as a default but not actually exist in the input, use
placeholder
Just a head check... Where is
updates
/ updates.data
coming from? I know on v12 the field changed to renderData
instead if this is coming through a document update / TJSDocument
.This is still on v11. I'm constructing it based off an Item passed to the svelte app. (technically
action
, but it's a basically a document in pf1)
--> {#if updates.data.measureTemplate.color}
This line, it doesn't appear to be going off of the truthiness of color
. Right now color is an empty string but it's still entering this block
Either that, or it's not being rebuilt when the value is emptied because that second block isn't binding to it nowOh. If types are the issue then why not
Boolean(updates.data.measureTemplate.color)
?
That sounds more likely, as static Foundry things go.