It disappears because the code tells it to with !showExtraInfo (showExtraInfo is the scrolled state of the header):
if(!showExtraInfo) {
return [helper.widget.attach('header-theme-selector')];
}
If you change that entire api.decorateWidget block to:
api.decorateWidget('header-buttons:after', (helper)=>{
return [helper.widget.attach('header-theme-selector')];
});
Then it should continue to appear even when scrolled.