fix(ui): resolve relative hrefs to absolute paths before navigation

BUI link components with relative hrefs (e.g. `../other`) would
navigate to the wrong URL because React Aria's navigate callback
receives the raw href string and cannot resolve it correctly from
where it is called in Backstage's routing setup.

This adds a `resolveHref` flag to the component definition system.
When enabled, `useDefinition` calls `useHref()` to turn relative
hrefs into absolute paths before they reach the React Aria layer.
A compile-time type guard ensures components with `href` in their
props cannot omit the flag.

Signed-off-by: Johan Persson <johanopersson@gmail.com>
This commit is contained in:
Johan Persson
2026-03-26 16:38:33 +01:00
parent cf4b4789f1
commit d840ba9053
14 changed files with 73 additions and 4 deletions
@@ -0,0 +1,7 @@
---
'@backstage/ui': patch
---
Fixed relative `href` resolution for BUI link components. Relative paths like `../other` are now correctly turned into absolute paths before reaching the React Aria layer, ensuring client-side navigation goes to the right place.
**Affected components:** ButtonLink, Card, CellProfile, CellText, Link, ListRow, MenuItem, MenuListBoxItem, Row, SearchAutocompleteItem, Tab, Tag