You can use shift+dbl click on a container to collapse it in structures such as chests or barrels. Note that the containers must first be emptied before they can be collapsed. You can then use the placement menu to replace the item.