When you click on an item with your mouse and close the inventory, the item is not thrown out. Now, this in of itself is not really much of an issue, but the issue goes deeper; /clear also bugs with this. If you have an item held with your mouse and use /clear, the item that should have been cleared remains in your inventory
Steps to Recreate
1.) /give yourself any item
2.) Open your inventory and click on the item as if you're going to move it
3.) While the item is being held with your mouse, close the inventory
4.) Type /clear [item]
5.) Open your inventory and voila, you still have the item in your mouse
Again, this isn't some massive security flaw or anything massive, but it can be an inconvenience at times if someone knows this and uses it to their advantage
Related issues
Comments

Duplicate of MC-229985.

Thank you for your report!
We're tracking this issue in MC-229985, 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
-- I am a bot. This action was performed automatically! The ticket was resolved by one of our moderators, and I left this message to give more information to you.
⚠️ Please do not mark Unreleased Versions as affected. You don't have access to them yet.
-- I am a bot. This action was performed automatically! If you think it was incorrect, please notify us on Discord or Reddit