cockpit-project / cockpit

Cockpit is a web-based graphical interface for servers.
http://www.cockpit-project.org/
GNU Lesser General Public License v2.1
10.95k stars 1.1k forks source link

Service kebab menu is cut off by menu #17596

Open LunarTwilight opened 2 years ago

LunarTwilight commented 2 years ago

Explain what happens

  1. go to a systemd service (eg /system/services#/test.service)
  2. click on the kebab menu next to the name
  3. observe the kebab menu is cut off due to it being left aligned (changing it in my dev tools to be right aligned fixes it)

image

Version of Cockpit

264-1~bpo20.04.1

Where is the problem in Cockpit?

Services

Server operating system

Ubuntu

Server operating system version

20.04.4 LTS

What browsers are you using?

Chrome

System log

No response

garrett commented 2 years ago

Thanks for reporting!

I was able to reproduce this in both Chrome and Firefox with short systemd service names. It's important to note that at least on Fedora, none of the default services have names this short to see this problem.

The menu would be cut off on the right for long names and/or mobile mode if we changed the alignment.

Here's a screenshot in mobile, with a standard name:

image

I do have a test service and it does happen in mobile also, as the name is so short:

image

We could fix this for mobile, by always aligning the menu icon to the right. For desktop, it's trickier. A simple, but not correct, approach would be to add a min-width for the text, but then it's going to break like the top screenshot in various languages.

If we combine this with breakpoint alignment in the <Dropdown> component, we could have the position the same on desktop modes and right-aligned in mobile, then have

<Dropdown
  alignments={{
    default: 'right',
    sm: 'left'
  }}
  ...
>

To align it, we would add some CSS, like this, for a mobile-only breakpoint:

.service-top-panel .pf-c-dropdown {
  flex: auto;
  justify-content: end;
}

I think this can be done with PatternFly utilities:

pf-u-flex-grow-on-sm pf-u-justify-content-flex-end-on-sm

End result would look like this in mobile:

image

image

And like this on desktop:

image

LunarTwilight commented 2 years ago

Oh yeah, I forgot that cockpit has a mobile UI whoops. Your solution looks great.

jelly commented 1 year ago

See it here too:

image

Just create: ~/.config/systemd/user/a.service

[Unit]
Description=a

[Service]
ExecStart=/usr/bin/true

[Install]
WantedBy=default.target

And:

systemctl --user daemon-reload

Note that, the Dropdown component has position=right but that does nothing good for us. Removing that seems to do the right thing for me:

Desktop:

image

Mobile:

image