UK switches party leader mid term

I was wondering as I read about the UK Labour prime minister leaving office voluntarily part way through his term to make way for a more popular choice as leader – has something like this ever happened in Canada?