fix: the diagnostics tab keeps its focus, its level and its consent
Deep-review round 1 of E22. - After a 429 the stream sent one POST per new event while a full batch waited; it now stays quiet for 15 s. Past the queue cap the oldest events go, as the comment always said, a refused batch included. - A batch refused after the level was lowered came back into the queue of a later consent in the same tab; each consent is its own session. - A `me` fetch that left before a level or preference change could put the old value back for up to a minute. `updateMeCache` writes the cache and cancels that fetch; usePref goes through it too. - The consent box's buttons and "revert now" took the focus with them to <body>; it returns to the level picker. Watched until the button is gone — in Chrome the saved level arrives in two renders, and a one-shot check spent itself on the first (jsdom never showed it). - The countdown line is no longer a live region re-read every minute. - "Saját napló" rows were keyed by index on a newest-first list, so every new event remounted every row and dropped the focus off a row button.
This commit is contained in:
@@ -51,6 +51,21 @@ function useLogEvents(): LogEvent[] {
|
||||
return list;
|
||||
}
|
||||
|
||||
// A row's React key: the event OBJECT's own number, handed out the first time it is drawn. The ring
|
||||
// keeps the same objects, so the key stays put as the list grows at the top — an index key shifted
|
||||
// every row on every new event, remounting all of them and dropping the focus off the row button
|
||||
// (at Részletes a click on a row logs a line itself, so it happened on every click).
|
||||
const rowIds = new WeakMap<LogEvent, number>();
|
||||
let nextRowId = 0;
|
||||
const rowKey = (event: LogEvent) => {
|
||||
let id = rowIds.get(event);
|
||||
if (id === undefined) {
|
||||
id = nextRowId++;
|
||||
rowIds.set(event, id);
|
||||
}
|
||||
return id;
|
||||
};
|
||||
|
||||
const matches = (event: LogEvent, needle: string) =>
|
||||
!needle ||
|
||||
[event.event, event.msg, event.request_id ?? "", event.attrs ? JSON.stringify(event.attrs) : ""]
|
||||
@@ -151,11 +166,11 @@ export default function MyLogViewer() {
|
||||
{all.length === 0 ? t("settings.myLog.emptyAll") : t("settings.myLog.empty")}
|
||||
</p>
|
||||
) : (
|
||||
shown.slice(0, ROWS_SHOWN).map((e, i) => {
|
||||
shown.slice(0, ROWS_SHOWN).map((e) => {
|
||||
const tag = LEVEL_TAG[e.level];
|
||||
const isOpen = open === e;
|
||||
return (
|
||||
<div key={`${e.ts}-${i}`} className="border-b border-border/50 last:border-b-0">
|
||||
<div key={rowKey(e)} className="border-b border-border/50 last:border-b-0">
|
||||
<button
|
||||
type="button"
|
||||
aria-expanded={isOpen}
|
||||
|
||||
Reference in New Issue
Block a user