mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(boards bar): preserve catalog multiboard links
This commit is contained in:
@@ -125,6 +125,10 @@ let container: HTMLDivElement;
|
||||
let root: Root;
|
||||
|
||||
const findExactText = (text: string) => Array.from(container.querySelectorAll<HTMLElement>('*')).find((element) => element.textContent?.trim() === text);
|
||||
const getLinkHref = (text: string) =>
|
||||
Array.from(container.querySelectorAll<HTMLAnchorElement>('a'))
|
||||
.find((element) => element.textContent?.trim() === text)
|
||||
?.getAttribute('href');
|
||||
|
||||
const renderBoardsBar = async (initialEntry: string) => {
|
||||
await act(async () => {
|
||||
@@ -234,6 +238,16 @@ describe('BoardsBar', () => {
|
||||
expect(testState.navigateMock).toHaveBeenCalledWith('/new-board.eth');
|
||||
});
|
||||
|
||||
it('keeps catalog navigation on desktop multiboard and board links', async () => {
|
||||
await renderBoardsBar('/mu/catalog');
|
||||
|
||||
expect(getLinkHref('all')).toBe('/all/catalog');
|
||||
expect(getLinkHref('subs')).toBe('/subs/catalog');
|
||||
expect(getLinkHref('mod')).toBe('/mod/catalog');
|
||||
expect(getLinkHref('mu')).toBe('/mu/catalog');
|
||||
expect(getLinkHref('custom.eth')).toBe('/custom.eth/catalog');
|
||||
});
|
||||
|
||||
it('keeps catalog navigation on mobile board changes and hides the navbar on downward scroll', async () => {
|
||||
await renderBoardsBar('/mu/catalog');
|
||||
|
||||
|
||||
@@ -92,6 +92,7 @@ const BoardsBarDesktop = () => {
|
||||
const location = useLocation();
|
||||
const params = useParams();
|
||||
const isInCatalogView = isCatalogView(location.pathname, params);
|
||||
const catalogSuffix = isInCatalogView ? '/catalog' : '';
|
||||
const [showSearchBar, setShowSearchBar] = useState(false);
|
||||
const [showAllTemporarily, setShowAllTemporarily] = useState(false);
|
||||
const { openCreateBoardModal } = useCreateBoardModalStore();
|
||||
@@ -170,7 +171,7 @@ const BoardsBarDesktop = () => {
|
||||
{code}
|
||||
</span>
|
||||
) : (
|
||||
<Link to={`/${code}${isInCatalogView ? '/catalog' : ''}`} onClick={openDirectoryForPlaceholder}>
|
||||
<Link to={`/${code}${catalogSuffix}`} onClick={openDirectoryForPlaceholder}>
|
||||
{code}
|
||||
</Link>
|
||||
)}
|
||||
@@ -192,7 +193,7 @@ const BoardsBarDesktop = () => {
|
||||
|
||||
return (
|
||||
<span key={address}>
|
||||
{boardPath && boardPath.trim() ? <Link to={`/${boardPath}${isInCatalogView ? '/catalog' : ''}`}>{displayText}</Link> : <span>{displayText}</span>}
|
||||
{boardPath && boardPath.trim() ? <Link to={`/${boardPath}${catalogSuffix}`}>{displayText}</Link> : <span>{displayText}</span>}
|
||||
{index !== total - 1 && ' / '}
|
||||
</span>
|
||||
);
|
||||
@@ -201,11 +202,11 @@ const BoardsBarDesktop = () => {
|
||||
return (
|
||||
<div className={styles.boardNavDesktop}>
|
||||
<span className={styles.boardList}>
|
||||
[<Link to='/all'>all</Link> / <Link to='/subs'>subs</Link>
|
||||
[<Link to={`/all${catalogSuffix}`}>all</Link> / <Link to={`/subs${catalogSuffix}`}>subs</Link>
|
||||
{accountCommunityAddresses.length > 0 && (
|
||||
<>
|
||||
{' '}
|
||||
/ <Link to='/mod'>mod</Link>
|
||||
/ <Link to={`/mod${catalogSuffix}`}>mod</Link>
|
||||
</>
|
||||
)}
|
||||
]{' '}
|
||||
|
||||
Reference in New Issue
Block a user