Steps to Reproduce:
1. Make a setup like this.
[media]Placement: chest-hopper-rail-minecart with hopper-any solid block
2. Get yourself a stack of each item like bones, potatoes, and gunpowder.
3. Split the stack of each item randomly (for example, in a stack of bones, you split it into two, a 34-30 item split)
4. Place one of the split items into the chest.
5. Now, throw the other split item into the solid block above the Minecart with hopper.
6. Check the chest.
(Note: I observed that it works fine with the item nearest to the first slot with the same item, so try testing 3-4 items, each for every row.)
Observed Results:
Certain items do not stack up correctly when a hopper collects the items into a hopper.
First saw this issue on my automated trident killer farm. Observed items like potatoes, bones, arrows and gunpowder are the ones clogging the slots.
As you can see below, these items should fill the slots that are not yet a full-stack first, before taking those slots. (I did not highlight the potato but you can see that a potato was separated at the 3 potatoes below.)
[media]Expected Result:
Stackable Items being collected and stored on a chest should fill the slots with less than 64 items first before occupying a new slot.
Further Notes:
[media]I tested this on another world (you can see that from above) and from the item drop I made in the solid block above the minecart with hopper, the bones, gunpowder, and potato did not prioritise filling the incomplete stack of the same item, which is odd. (About the note I said earlier, the item nearest to the first slot do not seem to go with this bug. The rotten flesh filled the incomplete stack of itself but I suppose that happened because there are no more slots between them)
When items are pushed or pulled into a container (chest, barrel, hopper, etc), the first available slot will be used for the item. If there are empty slots before a partially-filled slot containing the item, the empty slot will be used first.
This behavior is well-known in the community and has been this way for many years.