When you enter a room and you immediately open the inventory, the third item of the third row will get selected, because that's where the cursor will be. So, if you've selected another item in advance, you have to get the cursor out of the way before opening the inventory.
For example, you can do so before using the shovel with the X on Dinky Island.