Fix flicker in short context menus that have documentation aside (#38074)
Menu items in the context menu component have the ability to display a documentation aside popover. However, because this docs aside popover was setup as a sibling flex container to the actual menu popover, if the menu had a short amount of items and the docs popover is bigger than the menu, this flickering would happen, making it essentially unusable: https://github.com/user-attachments/assets/74956254-fff6-4c5c-9f79-02998c64a105 So, this PR makes the docs aside popover in wide window sizes absolutely-positioned relative to the menu container, which removes all flickering. On top of that, I'm adding a `DocumentationEdge` enum that allows to control the edge anchor of the docs aside, which is useful in this particular mode selector example to make the layout work well. https://github.com/user-attachments/assets/a3e811e1-86b4-4839-a219-c3b0734532b3 When the window is small, the docs aside continue to be a sibling flex container, which causes a super subtle shift in the items within the menu popover. This is something I want to pursue fixing, but didn't want to delay this PR too much. Release Notes: - N/A
This commit is contained in:
@@ -20,8 +20,8 @@ use project::project_settings::DiagnosticSeverity;
|
||||
use search::{BufferSearchBar, buffer_search};
|
||||
use settings::{Settings, SettingsStore};
|
||||
use ui::{
|
||||
ButtonStyle, ContextMenu, ContextMenuEntry, DocumentationSide, IconButton, IconName, IconSize,
|
||||
PopoverMenu, PopoverMenuHandle, Tooltip, prelude::*,
|
||||
ButtonStyle, ContextMenu, ContextMenuEntry, DocumentationEdge, DocumentationSide, IconButton,
|
||||
IconName, IconSize, PopoverMenu, PopoverMenuHandle, Tooltip, prelude::*,
|
||||
};
|
||||
use vim_mode_setting::VimModeSetting;
|
||||
use workspace::{
|
||||
@@ -401,7 +401,7 @@ impl Render for QuickActionBar {
|
||||
}
|
||||
});
|
||||
if !edit_predictions_enabled_at_cursor {
|
||||
edit_prediction_entry = edit_prediction_entry.documentation_aside(DocumentationSide::Left, |_| {
|
||||
edit_prediction_entry = edit_prediction_entry.documentation_aside(DocumentationSide::Left, DocumentationEdge::Top, |_| {
|
||||
Label::new("You can't toggle edit predictions for this file as it is within the excluded files list.").into_any_element()
|
||||
});
|
||||
}
|
||||
@@ -452,7 +452,7 @@ impl Render for QuickActionBar {
|
||||
}
|
||||
});
|
||||
if !diagnostics_enabled {
|
||||
inline_diagnostics_item = inline_diagnostics_item.disabled(true).documentation_aside(DocumentationSide::Left, |_| Label::new("Inline diagnostics are not available until regular diagnostics are enabled.").into_any_element());
|
||||
inline_diagnostics_item = inline_diagnostics_item.disabled(true).documentation_aside(DocumentationSide::Left, DocumentationEdge::Top, |_| Label::new("Inline diagnostics are not available until regular diagnostics are enabled.").into_any_element());
|
||||
}
|
||||
menu = menu.item(inline_diagnostics_item)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user