Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[character sheet] Labels around inputs cause page to jump to top

1461161939

Edited 1461162551
chris b.
Pro
Sheet Author
API Scripter
Is anyone else experiencing this? When I put a label around an input (such as a checkbox) then check the box. If I then reset the box value in a sheetworker (changing the value back to 0, to simulate a button that is pressed) The page scrolls back up to the top: <label>mytext <input type="checkbox" value="1" name="attr_something" /></label> on("change:something",function(){ getAttrs(["something"],function(v){ if(v["something']=="1"){ callSomeOtherFunction(); //reset button setAttrs({"something":"0"},{silent:true}); } }); }); If I don't put a label around it, then the character sheet stays in place when  I click the checkbox. <label for="pf-something" >mytext</label> <input type="checkbox" value="1" name="attr_something" id="pf-something" /> But I'd rather put labels around the inputs so that 1. the labels make sense and 2. is easier (no need for customizing width and size of the opacity 0 checkbox). Also 3. for="id" doesn't do anything useful due to the multiple copies in memory (though I notice the 5e OGL sheet has labels with "for") I did some research and it seems this is a javascript issue. And the only way around it seems to be to call objectThatThrewEvent.preventDefault() or return false to the browser, neither of which we can do. stackoverflow similar issue And obviously those changes have other implications. It is just really odd that it only happens if the input is wrapped by label, and not otherwise. Is there a way this can be fixed from the server side so a label around a checkbox does not cause this behavior? 
1461180667
Phil B.
Forum Champion
Sheet Author
I tried this with the following code and had no luck in recreating the issue. If you could figure out a specific, and hopefully simple, case where I can recreate it I will be able to try and fix it. But, with the following code I click the checkbox and it resets but it does not scroll back to the top. <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> // brs so I have to scroll <label>mytext <input type="checkbox" value="1" name="attr_something" /></label> <!-- WORKERS --> <script type="text/worker">     on("change:something",function(){         getAttrs(["something"],function(v){             if(v['something']=="1"){                  //reset button                  setAttrs({"something":"0"},{silent:true});             }         });     });      </script>
1461184930
chris b.
Pro
Sheet Author
API Scripter
thanks i'll try to create a simple example