Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Changelog
## [34.1.0] - 2026-09-09
- Show path to Navigation search results
## [33.0.1] - 2026-07-29
- Fix bug when exactly 100 rows hid the totals discovered on back post report (ticket 22250)
## [33.0.0] - 2026-06-05
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@linn-it/linn-form-components-library",
"version": "34.0.0",
"version": "34.1.0",
"private": false,
"repository": {
"type": "git",
Expand Down
15 changes: 13 additions & 2 deletions src/components/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function Navigation({
}) {
const [selected, setSelected] = useState(false);
const [anchorEl, setAnchorEl] = useState();
const [hoveredSectionId, setHoveredSectionId] = useState(null);
const { enqueueSnackbar, closeSnackbar } = useSnackbar();

const styles = {
Expand Down Expand Up @@ -99,6 +100,9 @@ function Navigation({

if (sections) {
const menuIds = sections.map(item => item.id);
const searchOpen = selected === sections.length;
const hoveredTabIndex = searchOpen ? menuIds.indexOf(hoveredSectionId) : -1;
const tabsValue = hoveredTabIndex !== -1 ? hoveredTabIndex : searchOpen ? false : selected;

const handleClick = event => {
setAnchorEl(event.currentTarget);
Expand Down Expand Up @@ -174,7 +178,7 @@ function Navigation({
<Grid size={9}>
<Tabs
sx={styles.tabs}
value={selected}
value={tabsValue}
onChange={(event, value) => {
if (selected === value) {
setSelected(false);
Expand Down Expand Up @@ -285,7 +289,14 @@ function Navigation({
)
)}
{selected === sections.length && (
<SearchPanel menu={sections} close={() => setSelected(false)} />
<SearchPanel
menu={sections}
close={() => {
setSelected(false);
setHoveredSectionId(null);
}}
onHoverSection={setHoveredSectionId}
/>
)}
</div>
</ClickAwayListener>
Expand Down
24 changes: 18 additions & 6 deletions src/components/Navigation.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,27 @@ const sampleSections = [
{
title: 'Purchase Orders',
items: [
{ title: 'Create PO', href: '#', showInMenu: true },
{ title: 'View POs', href: '#', showInMenu: true }
{
title: 'Create PO',
href: '/purchasing/orders/create',
showInMenu: true
},
{ title: 'View POs', href: '/purchasing/orders', showInMenu: true }
]
},
{
title: 'Suppliers',
items: [
{ title: 'Supplier List', href: '#', showInMenu: true },
{ title: 'Add Supplier', href: '#', showInMenu: true }
{
title: 'Supplier List',
href: '/purchasing/suppliers',
showInMenu: true
},
{
title: 'Add Supplier',
href: '/purchasing/suppliers/create',
showInMenu: true
}
]
}
]
Expand All @@ -36,8 +48,8 @@ const sampleSections = [
{
title: 'Orders',
items: [
{ title: 'Sales Orders', href: '#', showInMenu: true },
{ title: 'Invoices', href: '#', showInMenu: true }
{ title: 'Sales Orders', href: '/sales/orders', showInMenu: true },
{ title: 'Invoices', href: '/sales/invoices', showInMenu: true }
]
}
]
Expand Down
26 changes: 19 additions & 7 deletions src/components/Panel.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,24 @@ const sampleSection = {
{
title: 'Purchase Orders',
items: [
{ title: 'Create PO', href: '#', showInMenu: true },
{ title: 'View POs', href: '#', showInMenu: true },
{ title: 'Approve POs', href: '#', showInMenu: true }
{ title: 'Create PO', href: '/purchasing/orders/create', showInMenu: true },
{ title: 'View POs', href: '/purchasing/orders', showInMenu: true },
{
title: 'Approve POs',
href: '/purchasing/orders/approve',
showInMenu: true
}
]
},
{
title: 'Suppliers',
items: [
{ title: 'Supplier List', href: '#', showInMenu: true },
{ title: 'Add Supplier', href: '#', showInMenu: true }
{ title: 'Supplier List', href: '/purchasing/suppliers', showInMenu: true },
{
title: 'Add Supplier',
href: '/purchasing/suppliers/create',
showInMenu: true
}
]
}
]
Expand All @@ -28,8 +36,12 @@ const sampleSection = {
{
title: 'Invoices',
items: [
{ title: 'Invoice List', href: '#', showInMenu: true },
{ title: 'Overdue Invoices', href: '#', showInMenu: true }
{ title: 'Invoice List', href: '/purchasing/invoices', showInMenu: true },
{
title: 'Overdue Invoices',
href: '/purchasing/invoices/overdue',
showInMenu: true
}
]
}
]
Expand Down
67 changes: 49 additions & 18 deletions src/components/SearchPanel.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useMemo, useState } from 'react';
import Paper from '@mui/material/Paper';
import Box from '@mui/material/Box';
import Grid from '@mui/material/Grid';
Expand All @@ -24,24 +24,40 @@ const styles = {
}
};

function SearchPanel({ menu, close }) {
function SearchPanel({ menu, close, onHoverSection = () => {} }) {
const [searchTerm, setSearchTerm] = useState();

const menuEntries = menu
.map(s => s.columns)
.flat()
.map(c => c.categories)
.flat()
.map(i => i.items)
.flat();
const menuEntries = useMemo(
() =>
menu.flatMap(section =>
section.columns.flatMap(col =>
col.categories.flatMap(category =>
category.items.map(item => ({
...item,
sectionId: section.id,
breadcrumb:
`${section.title} > ${category.title} > ${item.title}`.replace(
/&amp;/g,
'&'
)
}))
)
)
),
[menu]
);

const uniqueEntries = Object.values(
menuEntries.reduce((uniques, entry) => {
if (!uniques[entry.href]) {
return { ...uniques, [entry.href]: entry };
}
return uniques;
}, {})
const uniqueEntries = useMemo(
() =>
Object.values(
menuEntries.reduce((uniques, entry) => {
if (!uniques[entry.href]) {
return { ...uniques, [entry.href]: entry };
}
return uniques;
}, {})
Comment on lines +53 to +58
),
[menuEntries]
);

const handleFieldChange = (propertyName, newValue) => {
Expand Down Expand Up @@ -82,12 +98,20 @@ function SearchPanel({ menu, close }) {
)
.map(entry => (
<Box key={entry.href}>
<a href={entry.href} style={{ textDecoration: 'none' }}>
<a
href={entry.href}
style={{ textDecoration: 'none' }}
onMouseEnter={() => onHoverSection(entry.sectionId)}
Comment on lines 100 to +104
onMouseLeave={() => onHoverSection(null)}
onFocus={() => onHoverSection(entry.sectionId)}
onBlur={() => onHoverSection(null)}
>
<ListItem
sx={{
paddingTop: 0,
paddingBottom: 0,
margin: 0
margin: 0,
gap: '8px'
}}
>
<Typography
Expand All @@ -97,6 +121,13 @@ function SearchPanel({ menu, close }) {
>
{entry.title}
</Typography>
<Typography
variant="caption"
color="text.secondary"
sx={{ margin: 0, lineHeight: 1.8 }}
>
{entry.breadcrumb}
</Typography>
</ListItem>
</a>
</Box>
Expand Down