It's not a bug. Once you've selected an item and seen the potential enchantment, you can't take back your choice anymore. You can either accept the new enchantment or keep your old enchantment. Closing to exit is equivalent to keeping your old enchantment.