Nav, Focus: Changed SetKeyboardFocusHere() to not behave if a drag or window moving is in progress + move KeepAliveID() call from Scrollbar() to ScrollbarEx()
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index b2a4e27..0661925 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -84,6 +84,7 @@
 - Nav: Fixed nav movement in a scope with only one disabled item from focusing the disabled item. (#5189)
 - Nav: Fixed issues with nav request being transferred to another window when calling SetKeyboardFocusHere()
   and simultaneous changing window focus. (#4449)
+- Nav: Changed SetKeyboardFocusHere() to not behave if a drag or window moving is in progress.
 - IsItemHovered(): added ImGuiHoveredFlags_NoNavOverride to disable the behavior where the
   return value is overriden by focus when gamepad/keyboard navigation is active.
 - InputText: Fixed pressing Tab emitting two tabs characters because of dual Keys/Chars events being
diff --git a/imgui.cpp b/imgui.cpp
index 57a4db6..3b5bcf2 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -7386,6 +7386,17 @@
     IM_ASSERT(offset >= -1);    // -1 is allowed but not below
     IMGUI_DEBUG_LOG_ACTIVEID("SetKeyboardFocusHere(%d) in window \"%s\"\n", offset, window->Name);
 
+    // It makes sense in the vast majority of cases to never interrupt a drag and drop.
+    // When we refactor this function into ActivateItem() we may want to make this an option.
+    // Note that g.ActiveId being stolen while g.MovingWindow != NULL is currently ill-defined (subtle side-effects on master, assert in docking),
+    // so there's another layer we need to fix. Would make sense to automatically drop g.MovingWindow when g.ActiveId is changed.
+    // MovingWindow is protected from most user inputs using SetActiveIdUsingNavAndKeys() but we may need to enforce a better more encompassing scheme.
+    if (g.DragDropActive || g.MovingWindow != NULL)
+    {
+        IMGUI_DEBUG_LOG_ACTIVEID("SetKeyboardFocusHere() ignored while DragDropActive!\n");
+        return;
+    }
+
     SetNavWindow(window);
 
     ImGuiScrollFlags scroll_flags = window->Appearing ? ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleEdgeY;
diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp
index 1a0b5c7..de8afbb 100644
--- a/imgui_widgets.cpp
+++ b/imgui_widgets.cpp
@@ -880,9 +880,7 @@
 {
     ImGuiContext& g = *GImGui;
     ImGuiWindow* window = g.CurrentWindow;
-
     const ImGuiID id = GetWindowScrollbarID(window, axis);
-    KeepAliveID(id);
 
     // Calculate scrollbar bounding box
     ImRect bb = GetWindowScrollbarRect(window, axis);
@@ -920,6 +918,8 @@
     if (window->SkipItems)
         return false;
 
+    KeepAliveID(id);
+
     const float bb_frame_width = bb_frame.GetWidth();
     const float bb_frame_height = bb_frame.GetHeight();
     if (bb_frame_width <= 0.0f || bb_frame_height <= 0.0f)