MDL-67513 core: Only move modal to body if currently attached