While I think this could be written in a better way, I have been frustrated by this issue before. In several lucky islands maps, there are workbenches like anvil, enchanting tables, smithing tables, etc. And the have become a nuisance when I accidentally open them during a fight. The better way to fix this would be to make it impossible to open these menus while holding a weapon.
However, another issue is that these menu blocks are almost completely useless. Whenever I’ve tried using an anvil, it always glitches out and doesn’t work properly, and there aren’t many cases where I get two items of the same type with enchantments that could be combined. Enchanting tables have a similar problem, as they require lapis and experience. In my opinion, these menu blocks are underutilized, and players should receive items that would allow them to use these workstations.