╭ changed ─────────────╮ │src/ui/Home/Header.zig│ ╰──────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────────────╮ │57 .min_size = .{ .width = 1, .height = null }, │ │58 }); │ │59 } │ │60 + │ │61 + // the tab matching the current page is focused initially; matching by│ │62 + // link (rather than position) keeps this robust to tab changes. │ │63 + const current_link: []const u8 = switch (session.data.current_page) { │ │64 + .home_repos => "a:/repos", │ │65 + .home_settings => "a:/settings", │ │66 + .home_auth => "a:/auth", │ │67 + else => "a:/users", │ │68 + }; │ │69 + var selected_tab: ?usize = null; │ │70 │ │71 // tabs │ │72 for ( │ ╰──────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │88 var auth_tab = try AuthTab.View.init(allocator, &data.auth_tab, session); │ │89 errdefer auth_tab.deinit(allocator); │ │90 try tab_ids.put(allocator, auth_tab.getFocus().id, {}); │ │91 + if (std.mem.eql(u8, focus_name, current_link)) selected_tab = auth_tab.getFocus().id;│ │92 try box.children.put(allocator, auth_tab.getFocus().id, .{ │ │93 .widget = .{ .auth_tab = auth_tab }, │ │94 .rect = null, │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │102 text_box.getFocus().focusable = true; │ │103 text_box.getFocus().kind = .{ .custom = focus_name }; │ │104 try tab_ids.put(allocator, text_box.getFocus().id, {}); │ │105 + if (std.mem.eql(u8, focus_name, current_link)) selected_tab = text_box.getFocus().id;│ │106 try box.children.put(allocator, text_box.getFocus().id, .{ │ │107 .widget = .{ .text_box = text_box }, │ │108 .rect = null, │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────╮ │127 } │ │128 │ │129 var self = View{ .box = box, .data = data, .tab_ids = tab_ids }; │ │118 - // initial selected tab │ │119 - self.getFocus().child_id = self.tab_ids.keys()[ │ │120 - switch (session.data.current_page) { │ │121 - .home_users => 0, │ │122 - .home_repos => 1, │ │123 - .home_settings => 2, │ │124 - .home_auth => 3, │ │125 - else => 0, │ │126 - } │ │127 - ]; │ │130 + self.getFocus().child_id = selected_tab orelse self.tab_ids.keys()[0];│ │131 return self; │ │132 } │ │133 │ ╰───────────────────────────────────────────────────────────────────────────────────╯