If sweet berries are in the player's main hand, and the player is targeting a block on which they cannot be planted, including ones in walls and ceilings, the item in the off-hand will not be used. if the player uses the "use item" action.
Â
EDIT: This is with a full hunger bar
Related issues
Comments

Reopened as this doesn't seem to be a block action.

Seems like a duplicate of MC-126337 to me. When aiming at a block you are trying to place the sweet berries. If your hunger bar isn't full and you cannot place the berry bush at the block you are aiming you will eat it instead. In general you probably shouldn’t be able to use the item in your offhand when you cannot eat the item because your hunger bar is full see MC-135143. Since you are instead trying to place the sweet berries and you are in general supposed to not use the item in your offhand when the block in your mainhand cannot be placed you won't use the item in your offhand while holding sweet berries when aiming at a block.
Thank you for your report!
However, this issue is a Duplicate of MC-160926.
Please use the search function in the future to prevent duplicate reports.
Quick Links:
📓 Issue Guidelines – 💬 Community Support – 📧 Customer Support – 📖 Game Wiki