netbox icon indicating copy to clipboard operation
netbox copied to clipboard

Rack visualization is stuck at light mode

Open jii8by opened this issue 4 months ago • 13 comments

Deployment Type

Self-hosted

NetBox Version

v4.3.5

Python Version

3.11

Steps to Reproduce

  1. Create site Example
  2. Create rack Rack 1 in site Example
  3. Go to rack details at /dcim/racks/1/

Expected Behavior

Since NetBox defaults to dark mode, rack visualization uses a dark background

Image

This image originates from version 4.3.0

Observed Behavior

Rack visualization uses a light background

Image

Current version of NetBox

This issue also occurs when viewing rack elevations at /dcim/rack-elevations/

jii8by avatar Aug 07 '25 15:08 jii8by

Can confirm same behaviour on v4.3.6. The device type images can barely be seen, and reading device names is a strain.

AliMickey avatar Aug 24 '25 23:08 AliMickey

same issue on 4.4

ITJamie avatar Sep 18 '25 10:09 ITJamie

Is this issue not affecting everyone or something for it to be not picked up?

The demo suffers from this regression.

Image

AliMickey avatar Nov 02 '25 12:11 AliMickey

@AliMickey would you like to volunteer to own this issue?

jeremystretch avatar Nov 03 '25 13:11 jeremystretch

@jeremystretch Nope, I am not a qualified developer that can fix this for Netbox.

Thank you for the shout though.

AliMickey avatar Nov 03 '25 23:11 AliMickey

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.

github-actions[bot] avatar Dec 05 '25 04:12 github-actions[bot]

Are we just closing issues now because your enterprise customers haven't upgraded to an affected release yet :D

AliMickey avatar Dec 05 '25 05:12 AliMickey

@AliMickey I asked earlier if you wanted to fix this and you declined. It appears no one else was interested in owning it either. Such is the nature of open source.

We'll be happy to re-open this should a volunteer step up to own it.

jeremystretch avatar Dec 05 '25 13:12 jeremystretch

Such is the case of open source that charges thousands per year and doesn't have middle ground for donations to incentivise more volunteers.

AliMickey avatar Dec 05 '25 13:12 AliMickey

You're certainly free to pay someone else to contribute a fix. You don't need us for that.

jeremystretch avatar Dec 05 '25 13:12 jeremystretch

Hey it's me, the volunteer. Decided to take a look during my lunch since this was annoying me.

Taking a look at the source it appears the svg object is being missed by the query:

https://github.com/netbox-community/netbox/blob/6efb258b9fe7281535a88ea729cdf5c64619684f/netbox/project-static/src/colorMode.ts#L30-L36 Specifically:

const svg = elevation.contentDocument?.querySelector('svg') ?? null; 

The elevation object doesn't have a contentDocument underneath it. A quick test of swapping it to select by children (And verifying it's an SVG) seems to have worked.

  for (const elevation of getElements<HTMLObjectElement>('.rack_elevation')) {
    const svg = elevation.children[0] ?? null;
    if (svg !== null && svg.nodeName == 'svg') {
      svg.setAttribute(`data-bs-theme`, targetMode);
    }
Image

This solution feels hacky though since I'm selecting the only child of the class element. I'm not sure where the contentDocument went since it was there in the past. I haven't worked with JS or TS in some time so if you know a better way then let me know!

A change ~4 months ago modified how the svg is generated which seems to be the earliest point of this bug: https://github.com/netbox-community/netbox/issues/19902#issue-3238576106 Notice how the screenshots show SVG with a white background, even though user is in dark mode. I don't think made this bug just the earliest I found it.

UnknownTy avatar Dec 05 '25 21:12 UnknownTy

Hey it's me, the volunteer.

@UnknownTy happy to reopen this and assign it to you if you're committing to submit a PR.

jeremystretch avatar Dec 07 '25 15:12 jeremystretch

Sure, send it my way.

UnknownTy avatar Dec 07 '25 19:12 UnknownTy

@UnknownTy do you still intend to work on this?

jeremystretch avatar Dec 17 '25 18:12 jeremystretch

@jeremystretch Yes! Apologies, rush of changes for work & life before Christmas.

I'm on break next week so plenty of free time (I hope ;) )

UnknownTy avatar Dec 18 '25 22:12 UnknownTy