╭ changed ───────────────╮ │src/ui/widget/thread.zig│ ╰────────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1363 } │ │1364 } │ │1365 │ │1366 - if (supports_drafts and entryDraft(entry) and !description_page and comment_page == null) {│ │1367 - try self.data.appendDraftDetails(allocator, inner, self.session, entry); │ │1366 + if (supports_drafts and !description_page and comment_page == null) { │ │1367 + try self.data.appendDetails(allocator, inner, self.session, entry); │ │1368 } │ │1369 │ │1370 if (comment_page) |page| { │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1467 break :blk tb.getFocus().id; │ │1468 }; │ │1469 │ │1470 - if (supports_drafts and entryDraft(entry)) { │ │1471 - inner.getFocus().child_id = inner.children.keys()[tool_row_index + 1]; │ │1472 - const sc = self.detailScroll(index); │ │1473 - sc.x = 0; │ │1474 - sc.y = 0; │ │1475 - sc.getFocus().version +%= 1; │ │1476 - return; │ │1477 - } │ │1470 + if (!supports_drafts or !entryDraft(entry)) { │ │1471 + const parent_route = ui.RoutablePage.repoThreadCommentsRoute(kind, self.data.identity, entry.id, 0) orelse return error.RouteTooLong; │ │1472 + try Attachment.appendRows(allocator, inner, self.session, self.data.identity, try parent_route.toUrl(self.session.page_arena), entry.attachments); │ │1473 │ │1479 - const parent_route = ui.RoutablePage.repoThreadCommentsRoute(kind, self.data.identity, entry.id, 0) orelse return error.RouteTooLong; │ │1480 - try Attachment.appendRows(allocator, inner, self.session, self.data.identity, try parent_route.toUrl(self.session.page_arena), entry.attachments); │ │1474 + if (!description_page) { │ │1475 + var reply = try Comment.linkBox(allocator, self.session, "new comment", ui.RoutablePage.repoThreadCommentNewRoute(kind, self.data.identity, entry.id, "") orelse return error.RouteTooLong);│ │1476 + errdefer reply.deinit(allocator); │ │1477 + try inner.children.put(allocator, reply.getFocus().id, .{ .widget = .{ .text_box = reply }, .rect = null, .min_size = null }); │ │1478 │ │1482 - if (!description_page) { │ │1483 - var reply = try Comment.linkBox(allocator, self.session, "new comment", ui.RoutablePage.repoThreadCommentNewRoute(kind, self.data.identity, entry.id, "") orelse return error.RouteTooLong); │ │1484 - errdefer reply.deinit(allocator); │ │1485 - try inner.children.put(allocator, reply.getFocus().id, .{ .widget = .{ .text_box = reply }, .rect = null, .min_size = null }); │ │1486 - │ │1487 - try Comment.appendCount(allocator, inner, entry.comments.count, "comment", "comments"); │ │1488 - for (entry.comments.comments) |comment| try Comment.appendComment(allocator, inner, self.session, self.data.identity, kind, comment); │ │1489 - try Comment.appendWindowNav(allocator, inner, self.session, self.data.identity, kind, entry.id, null, entry.comments); │ │1479 + try Comment.appendCount(allocator, inner, entry.comments.count, "comment", "comments"); │ │1480 + for (entry.comments.comments) |comment| try Comment.appendComment(allocator, inner, self.session, self.data.identity, kind, comment); │ │1481 + try Comment.appendWindowNav(allocator, inner, self.session, self.data.identity, kind, entry.id, null, entry.comments); │ │1482 │ │1491 - var spacer = try Spacer.init(allocator); │ │1492 - errdefer spacer.deinit(allocator); │ │1493 - try inner.children.put(allocator, spacer.getFocus().id, .{ .widget = .{ .spacer = spacer }, .rect = null, .min_size = null }); │ │1483 + var spacer = try Spacer.init(allocator); │ │1484 + errdefer spacer.deinit(allocator); │ │1485 + try inner.children.put(allocator, spacer.getFocus().id, .{ .widget = .{ .spacer = spacer }, .rect = null, .min_size = null }); │ │1486 + } │ │1487 } │ │1488 │ │1496 - // select the title by default │ │1497 - if (self.title_id[index]) |id| inner.getFocus().child_id = id; │ │1489 + // select the first focusable widget below the tool row │ │1490 + for (tool_row_index + 1..inner.children.count()) |child_index| { │ │1491 + if (!self.detailChildFocusable(index, child_index)) continue; │ │1492 + inner.getFocus().child_id = inner.children.keys()[child_index]; │ │1493 + break; │ │1494 + } │ │1495 │ │1496 // reset the scroll to the top for the newly-shown thread: directly on the │ │1497 // terminal (the wasm offset), and via a version bump on the web (so the │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────╮ │1579 return; │ │1580 } │ │1581 switch (key) { │ │1585 - .enter, .arrow_right => self.focusDetail(index, root_focus),│ │1582 + .enter, .arrow_right => _ = self.focusDetail(root_focus), │ │1583 else => {}, │ │1584 } │ │1585 } │ ╰──────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────╮ │2499 self.detailScroll(index).scrollToRect(rect); │ │2500 } │ │2501 │ │2505 - // enter the detail pane. an empty pane can't be entered. │ │2506 - fn focusDetail(self: *This, index: usize, root_focus: *Focus) void { │ │2507 - if (self.detailInner(index).children.count() == 0) return; │ │2508 - root_focus.setFocus(self.detailOuter(index).getFocus().id); │ │2502 + // enter the detail at its first focusable widget below the tool row. │ │2503 + pub fn focusDetail(self: *This, root_focus: *Focus) bool { │ │2504 + const index = self.selectedSplitIndex() orelse return false; │ │2505 + for (tool_row_index + 1..self.detailInner(index).children.count()) |child_index| {│ │2506 + if (!self.detailChildFocusable(index, child_index)) continue; │ │2507 + self.focusDetailChild(index, child_index, false, root_focus); │ │2508 + return true; │ │2509 + } │ │2510 + return false; │ │2511 } │ │2512 │ │2513 // return to the list. │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────╯