<sp-slider> requires a string value to set it to zero

This is new and really weird.

I have an sp-slider:

<sp-slider id="sliderColorValue" min="-64" max="64" value="0"></sp-slider>

There are times I want to programmatically set it to zero. I had been doing that with with:

document.getElementById("sliderColorValue").value = 0;

That was working fine, but not anymore. If I use that, it sets the slider to the maximum value (64). In order to set the slider to zero, it now requires:

document.getElementById("sliderColorValue").value = "0";

Only setting the slider to zero requires using the string value. For all other slider values, number values are fine.

I’m now testing for a value of zero for this slider and issuing a slider setter that uses the string value if it occurs, but that seems like a strange way to have to set a slider.

Addendum: I have multiple sp-sliders doing this, so I’m pretty sure it’s a real thing and not a one-off coding glitch.

Experienced the same here. What also works (although paradox):

document.getElementById("slider").value = new Number(0);

Weird indeed, i’m running PS 22.3.1 on Mac and it’s fine.
Are you running Mac/Win and PS > 22.3.1 ?

I’m running Ps 22.4.1 on Windows and am pretty sure it started with 22.4.1. It was fine before in 22.3.1 as far as I know. I hadn’t tested the sliders in a while in 22.3.1, but had no complaints. After 22.4.1 was released was when I first noticed it. I’ve also not tested it on Mac (the problem or the fix).

That’s what I thought. I have to stay away from 22.4/22.4.1, too much troubles with it. Hopefully some of these glitches will eventuallt fade away :sweat_smile:

What the… ?

Also, this works:

document.getElementById("sliderColorValue").setAttribute("value", 0);

Something must be goofed on the setter, but I don’t know why it would be different. Will dig in further.

Using a string value for zero (“0”) seems to work to properly set the sp-slider to zero on Mac and Windows in Ps 22.4.1. Not sure how it will work in previous/future versions of Ps, though. Kerri’s and Michel77’s method’s at least maintain the Number characteristic for the value.

When using console.log(host.version); PS 22.4.1 identifies itself as 22.4.0. I assume someone tried to fix some 2.4 issues with hot needles. Downward spiral :wink: