mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 12:35:14 +00:00
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.
This commit is contained in:
parent
4c024e41cb
commit
7be78ec044
Notes:
github-actions[bot]
2025-02-17 11:56:33 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/7be78ec0447 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3561 Reviewed-by: https://github.com/gmta ✅
1 changed files with 12 additions and 6 deletions
|
@ -62,6 +62,14 @@ const selectTab = (tabButton, tabID, selectedTab, selectedTabButton) => {
|
|||
tab.style.display = "block";
|
||||
tabButton.classList.add("active");
|
||||
|
||||
// Apply any filtering if we have it
|
||||
let filterInput = tab.querySelector(".property-filter");
|
||||
let propertyTable = tab.querySelector(".property-table");
|
||||
if (filterInput && propertyTable) {
|
||||
filterInput.value = inspector.propertyFilterText || "";
|
||||
filterInput.dispatchEvent(new InputEvent("input"));
|
||||
}
|
||||
|
||||
return tab;
|
||||
};
|
||||
|
||||
|
@ -361,12 +369,12 @@ const setupPropertyFilter = inputId => {
|
|||
const filterInput = document.getElementById(`${inputId}-filter`);
|
||||
|
||||
filterInput.addEventListener("input", event => {
|
||||
const searchText = event.target.value.toLowerCase();
|
||||
inspector.propertyFilterText = event.target.value.toLowerCase();
|
||||
const tbody = document.getElementById(`${inputId}-table`);
|
||||
const rows = tbody.getElementsByTagName("tr");
|
||||
|
||||
for (let row of rows) {
|
||||
applyPropertyFilter(row, searchText);
|
||||
applyPropertyFilter(row, inspector.propertyFilterText);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -377,8 +385,6 @@ inspector.createPropertyTables = (computedStyle, resolvedStyle, customProperties
|
|||
let newTable = document.createElement("tbody");
|
||||
newTable.setAttribute("id", tableID);
|
||||
|
||||
let searchText = oldTable.parentNode.parentNode.querySelector(".property-filter").value;
|
||||
|
||||
Object.keys(properties)
|
||||
.sort((a, b) => {
|
||||
let baseResult = a.localeCompare(b);
|
||||
|
@ -403,8 +409,8 @@ inspector.createPropertyTables = (computedStyle, resolvedStyle, customProperties
|
|||
let valueColumn = row.insertCell();
|
||||
valueColumn.innerText = properties[name];
|
||||
|
||||
if (searchText) {
|
||||
applyPropertyFilter(row, searchText);
|
||||
if (inspector.propertyFilterText) {
|
||||
applyPropertyFilter(row, inspector.propertyFilterText);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue