╭ changed ─╮ │src/ui.zig│ ╰──────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────────────╮ │234 │ │235 self.scroll.x = 0; │ │236 self.scroll.y = 0; │ │237 - self.scroll.getFocus().child_id = null; │ │237 + // keep the focus tree in sync with the widget tree so setFocus can │ │238 + // descend even when the pane isn't laid out this build (e.g. narrow │ │239 + // terminal where only the focused pane fits). build's clear+addChild│ │240 + // would do this otherwise, but it gets skipped for unbuilt panes. │ │241 + inner_box.getFocus().clear(); │ │242 + inner_box.getFocus().child_id = null; │ │243 │ │244 for (items) |item| { │ │245 const line = try self.allocator.dupe(u8, item); │ ╰──────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │252 errdefer text_box.deinit(); │ │253 text_box.getFocus().focusable = true; │ │254 try inner_box.children.put(self.allocator, text_box.getFocus().id, .{ .widget = .{ .text_box = text_box }, .rect = null, .min_size = null });│ │255 + try inner_box.getFocus().addChild(text_box.getFocus(), .{ .width = 0, .height = 0 }, 0, 0); │ │256 } │ │257 │ │258 if (inner_box.children.count() > 0) { │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────╮ │253 - self.scroll.getFocus().child_id = inner_box.children.keys()[0];│ │259 + inner_box.getFocus().child_id = inner_box.children.keys()[0]; │ │260 } │ │261 } │ │262 │ ╰────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────╮ │263 pub fn build(self: *SelectableList, constraint: layout.Constraint, root_focus: *Focus) !void {│ │264 self.clearGrid(); │ │259 - const pane_has_focus = root_focus.grandchild_id == self.getFocus().id; │ │265 const children = &self.scroll.child.box.children; │ │266 for (children.keys(), children.values()) |id, *item| { │ │267 item.widget.text_box.options.border_style = if (self.getFocus().child_id == id) │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────╮ │263 - // pane_has_focus will be true if the widgets weren't yet in │ │264 - // the focus tree, and so setFocus stopped at the pane itself. │ │265 - // in this case, it should be treated as if it's selected. │ │266 - (if (root_focus.grandchild_id == id or pane_has_focus) .double else .single)│ │268 + (if (root_focus.grandchild_id == id) .double else .single) │ │269 else │ │270 .hidden; │ │271 } │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────╯