Skip to content

fix(ui): style the DataTables Column visibility popover - #17131

Merged
Maffooch merged 2 commits into
DefectDojo:devfrom
skywalke34:fix/column-visibility-menu
Dec 3, 2026
Merged

Maffooch merged 2 commits into
DefectDojo:devfrom
skywalke34:fix/column-visibility-menu

Conversation

@skywalke34

Copy link
Copy Markdown
Contributor

Description

Partially addresses #17130 (items 1 and 2; item 3, the Copy / PDF / Print buttons, is a product decision and stays open).

base.html loads DataTables Buttons without a styling package, and datatables-dd.css styles Buttons' own dt-* markup. It had no rules for the Buttons popover, so on every table with a Column visibility button:

  • The menu covered the page controls. div.dt-button-collection rendered position: static with no background. Buttons only places the popover under its button when the stylesheet makes it position: absolute (otherwise it skips its positioning code), so the list spread inline across the button bar and sat on top of the Column visibility button itself.
  • You couldn't tell which columns were visible. Buttons marks the items of visible columns with its own dt-button-active class. datatables-dd.css only styled .dt-button.active, the class the removed Bootstrap integration used, so visible and hidden columns looked identical.

This adds to datatables-dd.css only:

  • div.dt-button-collection: absolute, z-index above the table (below modals at 1050), white background, border, shadow, one column, max-height: 70vh with scrolling for long column lists.
  • A checkbox on each item, ticked for dt-button-active. It reuses the box and check-mark SVG of the app's Tailwind form checkboxes, so it matches the checkboxes elsewhere on the page.
  • div.dt-button-background: the transparent full-page layer Buttons uses to close the popover on an outside click.
  • div.dt-buttons becomes position: relative to anchor the popover.

The CSS is global, so it fixes all 9 templates that use colvis (findings list, finding groups, components, asset components, asset list, all engagements, engagement list, view test, view finding's Similar Findings) with no template changes.

Before After
All Findings, CWE hidden before after

Test results

  • New unittests/test_datatables_column_visibility_css.py (3 tests). All 3 fail on current dev and pass with this change:
    • the popover is position: absolute with a z-index and a non-transparent background;
    • the backdrop is position: fixed; inset: 0;
    • there is a style for .dt-button-collection .dt-button.dt-button-active.
  • Verified live (Chrome, 1440px), opening the menu and hiding one column on 7 pages: /finding, /components, /asset/<id>/components, /asset, /engagements_all, /test/<id>, and /finding/<id> (Similar Findings, after expanding the panel). On each, the popover sits 4px below its button, left-aligned, white, and the number of ticked items equals the number of visible columns. There's no horizontal page scroll, and clicking outside or pressing Escape closes it. The finding-groups table and the engagement-list snippet weren't reachable with my data; they load the same stylesheet.
  • ruff check passes.

Documentation

None needed (bug fix).

Checklist

  • Rebased against the latest dev.
  • Submitted against the dev branch.
  • Meaningful PR name.
  • Ruff compliant.
  • Python 3.13 compliant.
  • New feature documentation: n/a, bug fix.
  • Migrations: n/a, no model changes.
  • Unit tests added.
  • Labels and milestone applied.

Generated with Claude Code under the direction of T. Walker (skywalke34) - DefectDojo

base.html loads DataTables Buttons without a styling package, and
datatables-dd.css had no rules for the Buttons popover, so on every table
with a Column visibility button:

- The popover rendered with position: static and no background. Buttons only
  places it under its button when the stylesheet makes it absolute, so it
  spread inline across the button bar and covered the Column visibility
  button itself.
- Visible and hidden columns looked identical. Buttons marks the items of
  visible columns with its own dt-button-active class; the file only styled
  .active, the class the removed Bootstrap integration used.

Adds rules for div.dt-button-collection (absolute, z-index, background,
border, shadow, one column), a checkbox on each item that is ticked for
dt-button-active (matching the app's Tailwind form checkboxes), and the
transparent full-page div.dt-button-background that closes the popover when
clicked. .dt-buttons becomes position: relative to anchor the popover.

Authored by T. Walker - DefectDojo

@Maffooch Maffooch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: #17131 fix(ui): style the DataTables Column visibility popover

Verdict: request-changes
Head SHA reviewed: 3191a20
Base: dev (milestone 3.6.0, the earliest open future milestone, correct)
Profile: code change (CSS only, plus a CSS-parsing unit test)

Summary

On a full page of findings the popover now looks and behaves right: it floats under the button, it's white, visible columns are ticked, and Escape and backdrop clicks close it. But on a short table it regresses. The popover is position: absolute inside the findings panel, and that panel has overflow-x: scroll; overflow-y: auto (.panel.table-responsive). Any table shorter than the menu clips it to the panel height. On dev the same menu was ugly but every item could be clicked.

Blocking

  1. Popover is clipped by the .table-responsive panel on short tables. dojo/static/dojo/css/datatables-dd.css:378-390 (div.dt-button-collection { position: absolute; ... max-height: 70vh }).
    • Repro: /finding/open?title=<one match> (1 row), 1200x863 viewport, open Column visibility. The popover is 604px tall and the panel is 207px tall (scrollHeight 656). Only 4 of 21 items can be hit with elementFromPoint. The rest sit below the panel's bottom edge and you only reach them by scrolling the panel itself.
    • Same page with datatables-dd.css reset to origin/dev: 21 of 21 items clickable (the static inline layout grows the panel). So this PR introduces the regression.
    • Short tables are common: filtered finding lists, a test with a few findings, Similar Findings on view_finding, small asset component lists.
    • Possible fixes (pick one): let the popover escape the panel. Options include Buttons' non-absolute path (style it position: fixed and centered, which Buttons already supports via its place() fallback), dropping overflow on the panel while the popover is open, or capping max-height to the space actually available. Whatever the fix, add a check with a 1-row table.

Attempts

# What I did Expected Got Result
1 Reverted datatables-dd.css to origin/dev and ran the new tests fail on dev, pass on PR 3/3 fail on dev, 3/3 pass on PR no break
2 Full findings list (25 rows): open popover, check position, z-index, background, hit test of a middle item, horizontal scroll floats under button, clickable, no h-scroll absolute, z 1001, white, 4px under the button, middle item clickable, no h-scroll no break
3 Same list with dev CSS bug reproduces position: static, transparent, spread 922px wide across the bar confirms the bug on dev
4 Hide CWE, read tick state and table headers CWE unticked, column gone, ticked count drops dt-button-active removed, ::before white, 20 ticked, CWE header gone no break
5 Escape, then reopen and click the backdrop both close; backdrop removed both close, no stray dt-button-background no break
6 1-row table (title=RevFinding 60): count clickable items all 21 4 of 21 (popover clipped by .table-responsive, overflow auto) blocker
7 Same 1-row table on dev CSS for comparison 21 of 21 clickable confirms the regression is new
8 Checked the vendored Buttons 3.2.6 source for where the backdrop goes backdrop must sit under the popover Buttons inserts the backdrop right after the host button, the popover after that, both inside .dt-buttons. Same stacking context, 1000 vs 1001, so the popover sits on top no break
9 Grepped for other Buttons collections that would pick up the new ::before checkbox only colvis the 9 extend: 'colvis' templates, no other collection buttons no break

Nice to have

  • The tests parse CSS text with regexes, so they pin selectors and values, not behavior. They would not catch the clipping above. A short note in the PR saying this is a static guard is enough. A real layout check would need a browser test.
  • z-index: 1001 puts the popover above the fixed header if a user scrolls with it open. Minor.

Verified hands-on

Ran my own compose stack (dev image, source mounted) with 60 seeded findings. Drove /finding/open in Playwright (Chromium, 1200x863), on both PR CSS and dev CSS. Ran the new tests on the PR and with the fixed file reverted to dev. Ran ruff 0.16.10 on the tree with all five PRs merged (clean). All PR CI checks are green.

Static only / not reproduced

The other 8 colvis templates (components, asset components, asset list, engagements, engagement list snippet, view_test, view_finding Similar Findings, finding groups). Any of them inside a .table-responsive panel with few rows should clip the same way, but I only reproduced it on the findings list. Not checked on Firefox/Safari or at mobile width.

…ort table can't clip it

The popover was position:absolute under its button, inside the
.table-responsive panel (overflow: auto) around most tables. On a table with
one or two rows the panel clipped it, and only the first few columns could be
reached. position:fixed takes DataTables Buttons' centred placement path, which
the panel cannot clip. The backdrop is lightly dimmed to go with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@Maffooch Maffooch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review (round 2): #17131 fix(ui): style the DataTables Column visibility popover

Verdict: approve
Head SHA reviewed: 70cfa01
Base: dev (milestone 3.6.0, the earliest open future milestone, correct). The branch is 4 commits behind origin/dev and merges cleanly.
Profile: code change (CSS only, plus a CSS-parsing unit test)

Summary

The earlier blocker is fixed. The first review found that the position: absolute popover was clipped by the .table-responsive panel on short tables (4 of 21 items reachable on a 1-row findings list). Commit 70cfa01 makes the popover position: fixed, centred with top/left: 50% and translateX(-50%), and adds a light dimmed backdrop. Buttons 3.2.6 reads the computed position and, when it is not absolute, takes its "centre on screen" branch, which sets a negative margin-top of half the popover height (dataTables.buttons.mjs 1502 and 1614-1626, read from the published 3.2.6 tarball, the version in components/yarn.lock). So the vertical centring is Buttons' own supported path, not a fight with its JS. In a real browser, every item on every table I tried can now be reached and toggled at desktop and at 375px, and the popover closes with Escape and on a backdrop click.

Attempts

# What I did Expected Got Result
1 Ran the 3 new tests on the PR head, then with datatables-dd.css reset to origin/dev pass on PR, fail on dev PR: 3/3 pass. dev CSS: 3/3 fail no break
2 Ran the new tests against the first-review CSS (3191a20, the absolute version) the updated test should catch the clipping regression test_popover_floats_above_the_page fails with 'absolute' != 'fixed' no break (the test now guards the earlier blocker)
3 1-row findings list (/finding/open?title=RC+One), 1280x900. Open Column visibility, scroll each item into view, hit-test its centre with elementFromPoint, click it, check dt-button-active flips, click again, check it flips back 21/21 reachable and togglable position fixed, white, z 1001, 240x630 at top 140, internal scroll (scrollHeight 732). 21/21 reachable, 21/21 toggled, 21/21 restored no break (earlier blocker resolved)
4 25-row findings list (title=RC+Many, 30 findings, page size 25), 1280x900, same procedure 21/21 25 rows rendered. 21/21 reachable, toggled, restored no break
5 Both lists at 375x812 all reachable, no new horizontal scroll popover 240px wide at left 67, inside the viewport. 21/21 reachable, toggled, restored on both. Page scrollWidth is 501 with or without the popover, and also 501 on dev CSS, so the horizontal page scroll at 375 is pre-existing no break
6 View Test with 1 finding (/test/1) at 1280 and 375 13/13 13/13 reachable, toggled, restored at both widths no break
7 Close paths at each of the 6 page/width combinations: Escape; reopen and click the backdrop at the bottom-left corner closes, no stray dt-button-background closed and backdrop removed in all 6 for both Escape and backdrop click no break
8 Clicked the Column visibility button again while open closes closes at 1280. At 375 on the findings list the centred popover sits on top of the button, so the click lands inside the popover and it stays open (Escape and backdrop still close it) no break (expected for a centred modal-style popover)
9 Other colvis tables at 1280: asset list /product (9 items), /components (5), /product/2/components (5), asset findings /product/2/finding/open (20) all reachable, close on Escape all fixed, all items reachable and togglable, all closed no break
10 Same 1-row and 25-row pages with dev CSS, for the baseline bug present position: static, transparent. At 375 only 13 of 21 items hit-test without scrolling confirms the original bug on dev
11 Looked for a CSS transform/filter ancestor that would turn the fixed box back into a clipped one, and for a dark theme that the hard-coded white would break none transform appears in datatables-dd.css only on the popover itself and in the spinner keyframes. No prefers-color-scheme/data-theme rules in dojo/static/dojo/css. The hit-tests in attempts 3-9 confirm no ancestor clips it on those pages no break

Blocking

None.

Nice to have

  1. The tests still parse CSS text with regexes, so they pin selectors and values rather than layout. They now do catch a revert to absolute (attempt 2), which covers the earlier regression. A browser test would be the real guard. Not needed for this PR.
  2. On a phone the centred popover covers its own button, so tapping the button again does not close it. Escape and the backdrop work. Fine as is, mention only if someone reports it.

Verified hands-on

Own compose stack (project reviewc2, ports 38080/38443, Postgres and mailhog host ports removed) on a tree of origin/dev merged with both PR heads. Seeded via the REST API: one asset with 1 finding, one with 30. Drove Chromium through the Playwright MCP with real mouse clicks at 1280x900 and 375x812. Ran the new tests on the PR head, with the CSS reset to origin/dev, and with the first-review CSS. ruff 0.16.10 clean on the head. scripts/check_migration_leaves.py: single leaf. makemigrations --check: no changes. PR CI was still building Docker images when I checked, with no failures so far.

Static only / not reproduced

Firefox and Safari not tried. Engagement list, finding groups and the Similar Findings table on view_finding were not exercised: my seed data had no visible colvis button on /engagement/active or /finding/1. They use the same Buttons markup, so the CSS applies the same way, but that is by reading only.

@Maffooch
Maffooch added this pull request to the merge queue Dec 3, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 3, 2026
@Maffooch
Maffooch added this pull request to the merge queue Dec 3, 2026
Merged via the queue into DefectDojo:dev with commit f1292a4 Dec 3, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants