Index: src/org/openstreetmap/josm/gui/dialogs/SearchDialog.java
===================================================================
--- src/org/openstreetmap/josm/gui/dialogs/SearchDialog.java	(revision 19410)
+++ src/org/openstreetmap/josm/gui/dialogs/SearchDialog.java	(working copy)
@@ -28,6 +28,7 @@
 import javax.swing.text.Document;
 import javax.swing.text.JTextComponent;
 
+import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Filter;
 import org.openstreetmap.josm.data.osm.search.SearchCompiler;
 import org.openstreetmap.josm.data.osm.search.SearchMode;
@@ -91,6 +92,20 @@
         hcbSearchString = new AutoCompComboBox<>(model);
         this.searchSettings = new SearchSetting(initialValues);
         setContent(buildPanel(options));
+
+        // See #24333
+        if (!(initialValues instanceof Filter)) {
+            DataSet data = MainApplication.getLayerManager().getActiveDataSet();
+            if (data != null && data.getSelected().isEmpty()) {
+                remove.setEnabled(false);
+                inSelection.setEnabled(false);
+                if (this.searchSettings.mode == SearchMode.in_selection
+                        || this.searchSettings.mode == SearchMode.remove) {
+                    this.searchSettings.mode = SearchMode.replace;
+                    replace.setSelected(true);
+                }
+            }
+        }
     }
 
     /**
