Could have been a bug. I used the iOS simulator to reproduce this in Safari v15.5-v17.5. It seems like it was fixed in v18 though.