Skip to content

Commit 7be78ec

Browse files
AtkinsSJgmta
authored andcommitted
Inspector: Keep property filter across tabs
Remember the query, so that if you're filtering for "color" on the computed style tab, and switch to the resolved style tab, it's filtered for "color" too. This means we also can save looking up the filter text when a new node is inspected.
1 parent 4c024e4 commit 7be78ec

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Base/res/ladybird/inspector.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ const selectTab = (tabButton, tabID, selectedTab, selectedTabButton) => {
6262
tab.style.display = "block";
6363
tabButton.classList.add("active");
6464

65+
// Apply any filtering if we have it
66+
let filterInput = tab.querySelector(".property-filter");
67+
let propertyTable = tab.querySelector(".property-table");
68+
if (filterInput && propertyTable) {
69+
filterInput.value = inspector.propertyFilterText || "";
70+
filterInput.dispatchEvent(new InputEvent("input"));
71+
}
72+
6573
return tab;
6674
};
6775

@@ -361,12 +369,12 @@ const setupPropertyFilter = inputId => {
361369
const filterInput = document.getElementById(`${inputId}-filter`);
362370

363371
filterInput.addEventListener("input", event => {
364-
const searchText = event.target.value.toLowerCase();
372+
inspector.propertyFilterText = event.target.value.toLowerCase();
365373
const tbody = document.getElementById(`${inputId}-table`);
366374
const rows = tbody.getElementsByTagName("tr");
367375

368376
for (let row of rows) {
369-
applyPropertyFilter(row, searchText);
377+
applyPropertyFilter(row, inspector.propertyFilterText);
370378
}
371379
});
372380
};
@@ -377,8 +385,6 @@ inspector.createPropertyTables = (computedStyle, resolvedStyle, customProperties
377385
let newTable = document.createElement("tbody");
378386
newTable.setAttribute("id", tableID);
379387

380-
let searchText = oldTable.parentNode.parentNode.querySelector(".property-filter").value;
381-
382388
Object.keys(properties)
383389
.sort((a, b) => {
384390
let baseResult = a.localeCompare(b);
@@ -403,8 +409,8 @@ inspector.createPropertyTables = (computedStyle, resolvedStyle, customProperties
403409
let valueColumn = row.insertCell();
404410
valueColumn.innerText = properties[name];
405411

406-
if (searchText) {
407-
applyPropertyFilter(row, searchText);
412+
if (inspector.propertyFilterText) {
413+
applyPropertyFilter(row, inspector.propertyFilterText);
408414
}
409415
});
410416

0 commit comments

Comments
 (0)