Mathworks has acknowledged this as a bug and will hopefully get it fixed in a later release, however I need a workaround for the current release as there are other issues preventing me from using more recent versions.
Another bug, probably related: if you add a legend and then axtoolbar, the zoom stops working.
f = uifigure('HandleVisibility', 'on');
tileHandle = tiledlayout(f, 1, 1);
h = nexttile(tileHandle, 1);
line = plot(h, [0 1], [0 1], 'DisplayName', 'this legend triggers the error after call to axtoolbar on zoom button press');
lHandle = legend(h);
tb = axtoolbar(tileHandle, {'export', 'datacursor', 'pan', 'zoomin', 'zoomout', 'restoreview'});
If I hit the zoom button after this, I get this error:
Warning: Invalid argument at position 1. Value must be of type
matlab.graphics.axis.AbstractAxes or be convertible to
matlab.graphics.axis.AbstractAxes.
Error while evaluating ValueChangedFcn for axes toolbar.