fixes #285: unsync state in onchange handler