mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-06 18:46:49 +00:00
Scroll the collab panel when keyboard focusing
This commit is contained in:
parent
8638fc4149
commit
a37f86f294
2 changed files with 24 additions and 18 deletions
|
@ -1808,14 +1808,9 @@ impl CollabPanel {
|
||||||
self.selection = Some(ix);
|
self.selection = Some(ix);
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo!()
|
if let Some(ix) = self.selection {
|
||||||
// self.list_state.reset(self.entries.len());
|
self.scroll_handle.scroll_to_item(ix)
|
||||||
// if let Some(ix) = self.selection {
|
}
|
||||||
// self.list_state.scroll_to(ListOffset {
|
|
||||||
// item_ix: ix,
|
|
||||||
// offset_in_item: 0.,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1825,14 +1820,9 @@ impl CollabPanel {
|
||||||
self.selection = Some(ix - 1);
|
self.selection = Some(ix - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo!()
|
if let Some(ix) = self.selection {
|
||||||
// self.list_state.reset(self.entries.len());
|
self.scroll_handle.scroll_to_item(ix)
|
||||||
// if let Some(ix) = self.selection {
|
}
|
||||||
// self.list_state.scroll_to(ListOffset {
|
|
||||||
// item_ix: ix,
|
|
||||||
// offset_in_item: 0.,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2350,8 +2340,6 @@ impl CollabPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_signed_in(&mut self, cx: &mut ViewContext<Self>) -> Div {
|
fn render_signed_in(&mut self, cx: &mut ViewContext<Self>) -> Div {
|
||||||
dbg!(&self.scroll_handle.top_item());
|
|
||||||
|
|
||||||
v_stack()
|
v_stack()
|
||||||
.size_full()
|
.size_full()
|
||||||
.child(
|
.child(
|
||||||
|
|
|
@ -1491,4 +1491,22 @@ impl ScrollHandle {
|
||||||
Err(ix) => ix.min(state.child_bounds.len().saturating_sub(1)),
|
Err(ix) => ix.min(state.child_bounds.len().saturating_sub(1)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// scroll_to_item scrolls the minimal amount to ensure that the item is
|
||||||
|
/// fully visible
|
||||||
|
pub fn scroll_to_item(&self, ix: usize) {
|
||||||
|
let state = self.0.borrow();
|
||||||
|
|
||||||
|
let Some(bounds) = state.child_bounds.get(ix) else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
let scroll_offset = state.offset.borrow().y;
|
||||||
|
|
||||||
|
if bounds.top() + scroll_offset < state.bounds.top() {
|
||||||
|
state.offset.borrow_mut().y = state.bounds.top() - bounds.top();
|
||||||
|
} else if bounds.bottom() + scroll_offset > state.bounds.bottom() {
|
||||||
|
state.offset.borrow_mut().y = state.bounds.bottom() - bounds.bottom();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue