mentions: don't lose focus after select mention
Closes: https://github.com/damus-io/notedeck/issues/728 Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -218,6 +218,7 @@ impl<'a, 'd> PostView<'a, 'd> {
|
||||
out.response
|
||||
}
|
||||
|
||||
// Displays the mention picker and handles when one is selected.
|
||||
fn show_mention_hints(
|
||||
&mut self,
|
||||
txn: &nostrdb::Transaction,
|
||||
@@ -281,17 +282,22 @@ impl<'a, 'd> PostView<'a, 'd> {
|
||||
)
|
||||
.show_in_rect(hint_rect, ui);
|
||||
|
||||
let mut selection_made = None;
|
||||
match resp {
|
||||
ui::mentions_picker::MentionPickerResponse::SelectResult(selection) => {
|
||||
if let Some(hint_index) = selection {
|
||||
if let Some(pk) = res.get(hint_index) {
|
||||
let record = self.note_context.ndb.get_profile_by_pubkey(txn, pk);
|
||||
|
||||
self.draft.buffer.select_mention_and_replace_name(
|
||||
mention.index,
|
||||
get_display_name(record.ok().as_ref()).name(),
|
||||
Pubkey::new(**pk),
|
||||
);
|
||||
if let Some(made_selection) =
|
||||
self.draft.buffer.select_mention_and_replace_name(
|
||||
mention.index,
|
||||
get_display_name(record.ok().as_ref()).name(),
|
||||
Pubkey::new(**pk),
|
||||
)
|
||||
{
|
||||
selection_made = Some(made_selection);
|
||||
}
|
||||
self.draft.cur_mention_hint = None;
|
||||
}
|
||||
}
|
||||
@@ -301,6 +307,10 @@ impl<'a, 'd> PostView<'a, 'd> {
|
||||
self.draft.buffer.delete_mention(mention.index)
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(selection) = selection_made {
|
||||
selection.process(ui.ctx(), textedit_output);
|
||||
}
|
||||
}
|
||||
|
||||
fn focused(&self, ui: &egui::Ui) -> bool {
|
||||
|
||||
Reference in New Issue
Block a user