diff --git a/Userland/Applications/Browser/BrowserWindow.cpp b/Userland/Applications/Browser/BrowserWindow.cpp index 17605bc13f..44351142e0 100644 --- a/Userland/Applications/Browser/BrowserWindow.cpp +++ b/Userland/Applications/Browser/BrowserWindow.cpp @@ -220,6 +220,9 @@ void BrowserWindow::build_menus() tab.m_dom_inspector_window->set_title("DOM inspector"); tab.m_dom_inspector_window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png")); tab.m_dom_inspector_window->set_main_widget(); + tab.m_dom_inspector_window->on_close = [&]() { + tab.m_page_view->document()->set_inspected_node(nullptr); + }; } auto* inspector_widget = static_cast(tab.m_dom_inspector_window->main_widget()); inspector_widget->set_document(tab.m_page_view->document()); diff --git a/Userland/Applications/Browser/InspectorWidget.cpp b/Userland/Applications/Browser/InspectorWidget.cpp index 11aa631407..9863c010f0 100644 --- a/Userland/Applications/Browser/InspectorWidget.cpp +++ b/Userland/Applications/Browser/InspectorWidget.cpp @@ -26,6 +26,7 @@ void InspectorWidget::set_inspected_node(GUI::ModelIndex const index) return; } auto* node = static_cast(index.internal_data()); + m_inspected_node = node; m_document->set_inspected_node(node); if (node && node->is_element()) { auto& element = verify_cast(*node); @@ -70,6 +71,7 @@ InspectorWidget::~InspectorWidget() void InspectorWidget::set_document(Web::DOM::Document* document) { + document->set_inspected_node(m_inspected_node); if (m_document == document) return; m_document = document; diff --git a/Userland/Applications/Browser/InspectorWidget.h b/Userland/Applications/Browser/InspectorWidget.h index 82f74084ab..afbd0e1eea 100644 --- a/Userland/Applications/Browser/InspectorWidget.h +++ b/Userland/Applications/Browser/InspectorWidget.h @@ -29,6 +29,8 @@ private: RefPtr m_style_table_view; RefPtr m_computed_style_table_view; + RefPtr m_inspected_node; + // One of these will be available, depending on if we're // in-process (m_document) or out-of-process (m_dom_json) RefPtr m_document;