╭ changed ───────────────────────╮ │src/ui/Repo/Issues/SubHeader.zig│ ╰────────────────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────────╮ │ 9 const Grid = xitui.grid.Grid; │ │10 const Focus = xitui.focus.Focus; │ │11 │ │12 -// tabs switching between the issues page's views. only "results" for now.│ │12 +// tabs switching between the issues page's views. │ │13 │ │14 pub const View = struct { │ │15 box: wgt.Box(ui.Widget), │ ╰──────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │16 tab_ids: std.AutoArrayHashMapUnmanaged(usize, void), │ │17 │ │18 // `tag` is the url-encoded tag filter ("" = unfiltered). │ │19 - pub fn init(allocator: std.mem.Allocator, session: *ui.Session, count: usize, tag: []const u8) !View { │ │19 + pub fn init(allocator: std.mem.Allocator, session: *ui.Session, identity: []const u8, count: usize, tag: []const u8) !View { │ │20 var box = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = .hidden, .rounded_corners = true, .direction = .horiz });│ │21 errdefer box.deinit(allocator); │ │22 │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │25 │ │26 const aa = session.page_arena.allocator(); │ │27 │ │28 + const results_route = ui.RoutablePage.repoIssuesRoute(identity, tag, "") orelse return error.RouteTooLong; │ │29 + const results_link = try std.fmt.allocPrint(aa, "ai:{s}", .{try results_route.urlAlloc(session.page_arena)});│ │30 + const tags_route = ui.RoutablePage.repoIssuesTagsRoute(identity) orelse return error.RouteTooLong; │ │31 + const tags_link = try std.fmt.allocPrint(aa, "ai:{s}", .{try tags_route.urlAlloc(session.page_arena)}); │ │32 + │ │33 // results tab, labeled with the listing's issue count │ │34 { │ │35 const label = try std.fmt.allocPrint(aa, "results ({d})", .{count}); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │36 var text_box = try wgt.TextBox(ui.Widget).init(allocator, label, .{ .border_style = .single, .rounded_corners = true, .wrap_kind = .none });│ │37 errdefer text_box.deinit(allocator); │ │38 text_box.getFocus().focusable = true; │ │39 + text_box.getFocus().kind = .{ .custom = results_link }; │ │40 try tab_ids.put(allocator, text_box.getFocus().id, {}); │ │41 try box.children.put(allocator, text_box.getFocus().id, .{ │ │42 .widget = .{ .text_box = text_box }, │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │54 var text_box = try wgt.TextBox(ui.Widget).init(allocator, label, .{ .border_style = .single, .rounded_corners = true, .wrap_kind = .none });│ │55 errdefer text_box.deinit(allocator); │ │56 text_box.getFocus().focusable = true; │ │57 + text_box.getFocus().kind = .{ .custom = tags_link }; │ │58 try tab_ids.put(allocator, text_box.getFocus().id, {}); │ │59 try box.children.put(allocator, text_box.getFocus().id, .{ │ │60 .widget = .{ .text_box = text_box }, │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────╮ │64 } │ │65 │ │66 var self = View{ .box = box, .tab_ids = tab_ids }; │ │60 - self.getFocus().child_id = self.tab_ids.keys()[0]; │ │67 + // the tab matching the incoming route's view is selected initially.│ │68 + const selected_index: usize = switch (session.data.current_page) { │ │69 + .repo_issues => |i| switch (i.view) { │ │70 + .results => 0, │ │71 + .tags => 1, │ │72 + }, │ │73 + else => 0, │ │74 + }; │ │75 + self.getFocus().child_id = self.tab_ids.keys()[selected_index]; │ │76 return self; │ │77 } │ │78 │ ╰────────────────────────────────────────────────────────────────────────────────╯