Don't allow minibrowser tab titles to be empty (#33229)

* avoid unnecessary clones when setting tab title in minibrowser

This is of course not a performance issue, but rather just bad style.
Especially since the url doesn't even need to be .clone()'d
in the first place.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Don't allow empty tab titles in minibrowser

These look very confusing. If the page has no title
its better to fall back to the url instead of displaying
absolutely nothing. (This is what firefox seems to do
too)

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
Simon Wülker 2024-08-28 18:57:28 +02:00 committed by GitHub
parent ef42ac0dfc
commit 7c4ba51f51
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -275,10 +275,10 @@ impl Minibrowser {
egui::Layout::left_to_right(egui::Align::Center),
|ui| {
for (webview_id, webview) in webviews.webviews().into_iter() {
let msg = match (webview.title.clone(), webview.url.clone()) {
(Some(title), _) => title,
(None, Some(url)) => url.to_string(),
_ => "".to_owned(),
let msg = match (&webview.title, &webview.url) {
(Some(title), _) if !title.is_empty() => title.clone(),
(_, Some(url)) => url.to_string(),
_ => "New Tab".to_owned(),
};
let tab = ui.add(SelectableLabel::new(
webview.focused,