Write a check into the list instead of rebuilding it
A check asks each saved search in turn and writes back what it found, and the list was built again from scratch on every one of those writes. So a background check -- which has no business being visible at all beyond a new count and a new time -- replayed the whole list's entry animation, threw away the reader's scroll position, and took the pointer out of whatever row it was over, several times over. Rows are now matched by id and told what changed: the count, the name, the line underneath, nothing else. A row is only built when it is new, gone, or changes shape, and the entry animation belongs to a row that has arrived rather than to every row every time. One mid-rename or mid-confirm is left alone entirely, so a check can no longer type over the reader. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MPZFnNdHbPGDTqQUNiE4ZN
This commit is contained in:
@@ -58,6 +58,20 @@ ROWS = """() => Array.from(document.querySelectorAll('#saved-panel .saved-row'))
|
||||
stamp: row.querySelector('.saved-row-stamp').textContent
|
||||
}))"""
|
||||
|
||||
MARK_ROWS = """() => {
|
||||
// A mark on the elements themselves: a rebuilt row cannot carry it.
|
||||
const rows = Array.from(document.querySelectorAll('#saved-panel .saved-row'));
|
||||
rows.forEach((row, i) => { row.dataset.probe = `p${i}`; });
|
||||
return rows.length;
|
||||
}"""
|
||||
|
||||
PROBES = """() => Array.from(document.querySelectorAll('#saved-panel .saved-row')).map((row) => ({
|
||||
probe: row.dataset.probe || '',
|
||||
count: row.querySelector('.saved-count').textContent,
|
||||
fresh: row.classList.contains('is-new'),
|
||||
stamp: row.querySelector('.saved-row-stamp').textContent
|
||||
}))"""
|
||||
|
||||
READ_BTN = """() => {
|
||||
const button = document.getElementById('saved-read-btn');
|
||||
return { disabled: button.disabled, text: button.textContent };
|
||||
@@ -378,6 +392,20 @@ def main():
|
||||
c.ok("and the button turns itself off with nothing left to clear",
|
||||
page.evaluate(READ_BTN)["disabled"] is True, str(page.evaluate(READ_BTN)))
|
||||
|
||||
print("\na check writes into the list without rebuilding it")
|
||||
c.ok("the list is open with a row in it", page.evaluate(MARK_ROWS) == 1)
|
||||
offset["at"] = offset["at"] + 2
|
||||
page.evaluate("() => App.savedSearches.check({ force: true })")
|
||||
page.wait_for_timeout(1000)
|
||||
rows = page.evaluate(PROBES)
|
||||
c.ok("the row is the same element it was before the check",
|
||||
len(rows) == 1 and rows[0]["probe"] == "p0", str(rows))
|
||||
c.ok("with the count written into it where it stood",
|
||||
rows[0]["count"] == "2", str(rows[0]["count"]))
|
||||
c.ok("and the time of the check with it",
|
||||
"checked" in rows[0]["stamp"].lower(), str(rows[0]["stamp"]))
|
||||
c.ok("nothing animated itself back in", rows[0]["fresh"] is False, str(rows[0]))
|
||||
|
||||
c.ok("nothing threw along the way", not crashes, str(crashes[:2]))
|
||||
browser.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user