While swimming you can regain air bubbles at around 0.8 blocks from water surface, if you do a strong attack on a mob while underwater and swimming. If you were not swimming, hit a mob and started swimming the bug will not occur, and once you go over the surface it will be fixed.
Thank you for your report!
We're tracking this issue in MC-165802, so this ticket is being resolved and linked as a duplicate.
If you would like to add a vote and any extra information to the main ticket it would be appreciated.
If you haven't already, you might like to make use of the search feature to see if the issue has already been mentioned.
Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki