From 925dc87cd14f2fc879456350c363e4755ea77779 Mon Sep 17 00:00:00 2001 From: Sebastian Sebbie Silbermann Date: Thu, 22 Jan 2026 14:49:06 +0100 Subject: [PATCH] [DevTools] Update inspected element on component filter changes --- packages/react-devtools-shared/src/backend/agent.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/react-devtools-shared/src/backend/agent.js b/packages/react-devtools-shared/src/backend/agent.js index a7c237be721..ee7b0588203 100644 --- a/packages/react-devtools-shared/src/backend/agent.js +++ b/packages/react-devtools-shared/src/backend/agent.js @@ -1086,6 +1086,15 @@ export default class Agent extends EventEmitter<{ } renderer.updateComponentFilters(componentFilters); } + + // Due to the component filters changing, we might be able + // to select a closer match for the currently selected host element. + // The store will already select a suitable parent if the the current + // selection is now filtered out in which cases this will be a no-op. + const target = window.__REACT_DEVTOOLS_GLOBAL_HOOK__.$0; + if (target != null) { + this.selectNode(target); + } }; getEnvironmentNames: () => void = () => {