fix(graph): make the entity type legend collapsible - #109
Open
Ravi chandu Edru (RaviChanduEdru) wants to merge 1 commit into
Open
Ravi chandu Edru (RaviChanduEdru) wants to merge 1 commit into
Ravi chandu Edru (RaviChanduEdru) wants to merge 1 commit into
Conversation
The legend is absolutely positioned over the graph canvas with no way to close, minimize, or move it, and it renders one row per entity type with no bound. On a large ontology it grows until it blankets the nodes it is meant to annotate - the overlay complaint in microsoft#87, where the reporter could not find any way to dismiss it. Outside the mobile breakpoint, which hides the legend entirely, there was no escape. Give the legend a header button that collapses it to a single pill showing the title and the entity type count, persisted to localStorage so the choice survives a reload. When the user has expressed no preference, the legend opens collapsed for ontologies above LEGEND_AUTO_COLLAPSE_THRESHOLD entity types, and re-applies that heuristic when a much larger ontology is loaded into an open session - so importing a big taxonomy no longer buries the graph. An explicit toggle always wins over the heuristic. Cap the expanded body at 45% of the canvas height with internal scrolling, so even an unbounded entity list cannot cover the graph. Extracted to GraphLegend.tsx: it now owns state, and OntologyGraph is already 590 lines and mounts cytoscape on render, which makes it impractical to reach in jsdom. The toggle carries aria-expanded and aria-controls, plus an aria-label that keeps the visible "Entity Types" text inside the accessible name (WCAG 2.5.3) - without it the button announced as "Entity Types3". Verified against the running app with Playwright: default ontology expands with all 6 rows, collapses to the pill, and stays collapsed across a reload; a 19-entity catalogue ontology opens collapsed, and expanding it stays inside the canvas (376px of 836px) with all 19 rows scrollable. No console errors.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the first item of #87 — "a popup or overlay appears over the graph and obscures the nodes. I could not find an option to close, minimize, or move it."
The problem
The entity-type legend is absolutely positioned over the graph canvas and renders one row per entity type with no bound:
There is no close, collapse, or move affordance anywhere — the only place it gets hidden is the mobile breakpoint, which drops it with
display: none. On a large ontology it grows until it blankets the nodes it exists to annotate, which is what the reporter's screenshot shows.The change
localStorage, so it survives a reload.LEGEND_AUTO_COLLAPSE_THRESHOLD(12) entity types, and re-applies that heuristic when a much larger ontology is loaded into an already-open session — so importing a big taxonomy doesn't bury the graph. An explicit toggle always wins over the heuristic.Extracted into
GraphLegend.tsx— it now owns state, andOntologyGraphis already ~590 lines and mounts cytoscape on render, which makes it impractical to reach in jsdom.OntologyGraph's diff is a one-line swap.Accessibility: the toggle carries
aria-expanded/aria-controls, plus anaria-labelthat keeps the visible "Entity Types" text inside the accessible name (WCAG 2.5.3) — without it the button announced as "Entity Types3". Only existing theme tokens are used, so the contrast suite is unaffected.Verification
10 new unit tests in
GraphLegend.test.tsxcover expand/collapse, persistence, the size heuristic, explicit-choice precedence, mid-session ontology growth, andlocalStoragebeing unavailable.Also driven against the running app with Playwright:
community/1010yab/university-class-search(19 types)No console errors in any state.
Notes
npm teston this branch shows one unrelated pre-existing failure,compile-catalogue.test.tstiming out under Vitest's 5s default, which is what fix(lint): repair no-case-declarations errors and gate lint in CI #108 fixes.