I agree with previous comments that Brexit was mostly about immigration. I don't think attitudes have changed much there. Sometimes events beyond a politician's control decide the outcome of elections. In this case, the Manchester bombing, and May's cuts to policing certainly had an impact that no one could have seen coming. Labour was able to free ride on that.