Fixing pending state change before attached to window