Keep NBT data of placeable item
Solution 1:
Since the item of a broken block always has a slight delay before it can be picked up, you can use that to give it the CanPlaceOn
tag:
execute as @e[type=item,nbt={Item:{id:"minecraft:redstone"}}] run data modify entity @s Item.tag.CanPlaceOn set value ["stone","dirt"]
This variant of the command might potentially cause slightly less lag, I haven't tested it:
execute as @e[type=item,nbt={Age:1,Item:{id:"minecraft:redstone"}}] run data modify entity @s Item.tag.CanPlaceOn set value ["stone","dirt"]
It only applies the change on items that were created 1 game tick ago.