That’s because after switching the size button, your code reported an error, which resulted in the subsequent code not being executed.
Hopefully it will help you. If yes then Please don’t forget hit Like and Mark it as solution!