observablehq / inputs

Better input elements
https://observablehq.com/framework/lib/inputs
ISC License
125 stars 34 forks source link

searchParam option for setting initial value #227

Open mbostock opened 2 years ago

mbostock commented 2 years ago

It’d be nice if this

viewof id = Inputs.text({label: "id", searchParam: "id"})

were shorthand for this

viewof id = Inputs.text({label: "id", value: new URLSearchParams(location.search).get("id")})
mythmon commented 2 years ago

With the second, I think it's clear that the value from the URL is only an initial value. For the first I would expect the URL would be kept up to date with changes to the input. That would be very cool, but not an exact equivalent. I also think Observable's iframe security model wouldn't allow it, right?

mbostock commented 2 years ago

I also think Observable's iframe security model wouldn't allow it, right?

Correct, not without reloading.