Tooltip bacgkround incorrect width

Open Beginner friendly
#3,735 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
67/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
rust
Domain
desktop, frontend

Research direction

Start with the tooltip component used by Tooltip::new in the reproduction, then trace how its content width and background size are laid out. Reproduce the issue with the supplied long tooltip text and compare the background with the text bounds. Done when the tooltip background correctly covers the longer text.

Written by the indexing model from the issue text.

Description

Description

Incorrect tooltip background size for longer texts

Environment

  • GPUI: gpui-fast: 0.1.12
  • GPUI Component: 0.8.1
  • Platform: Linux wayland

Steps to Reproduce

Compile this:

use gpui_kit::component::{ActiveTheme, tooltip::Tooltip};
use gpui_kit::*;

struct Repro;

impl Render for Repro {
    fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
        div()
            .size_full()
            .flex()
            .items_center()
            .justify_center()
            .bg(cx.theme().background)
            .text_color(cx.theme().foreground)
            .child(div().id("trigger").child("Hover here").tooltip(|window, cx| {
                Tooltip::new("Band AD_WBGT_20240621T00-20240621T23 - WBGT [time=477499]")
                    .max_w_96()
                    .build(window, cx)
            }))
    }
}

fn main() {
    gpui_kit::application().run(|cx| {
        gpui_kit::init(cx);
        if let Err(error) = gpui_kit::open_window(WindowOptions::default(), cx, |_, cx| cx.new(|_| Repro)) {
            eprintln!("Failed to open window: {error}");
            cx.quit();
            return;
        }
        cx.set_quit_mode(QuitMode::LastWindowClosed);
        cx.activate(true);
    });
}

Hover the mouse over "Hover here"
Inspect the tooltip

Screenshots

Image

Expected

Correct tooltip background

Actual

Incorrect tooltip background

Dominant language
Rust
Stars
18.9k
Forks
1.2k
Avg merge
23h 26m
Merged PRs (30d)
269

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from longbridge/gpui-kit

All issues in longbridge/gpui-kit

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.