Looks like you are using an iPhone Pro Max size in the simulator, which is why your first two examples work. If you run those examples on an iPhone Pro size, the overflow problem appears.
Thanks for the suggestion about the custom-built legend. Yes I'm aware that I can build a custom legend and have done so in other situations. Here I'd like to use the default legend, but it's not working. But I'll be sure to keep the custom-legend option in mind.