Dont deselect selected unit/structure when dialogs are open, that has to be closed by cancel hotkey (esc)
this refers also especialy to D297 having open a detail page of a production unit/structure from production menu and then close page by hitting esc put then not loosing production menu cause deselection happens also (to further interact with production menu).