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
3 changes: 3 additions & 0 deletions packages/styles/dist/gitlab-ui.css
Original file line number Diff line number Diff line change
Expand Up @@ -7387,6 +7387,9 @@
overflow: hidden;
white-space: nowrap;
}
.gl-collapsible-nav .gl-nav-item-chevron-slot {
margin-inline-start: auto;
}
.gl-collapsible-nav .gl-nav-item-addon, .gl-collapsible-nav .gl-nav-item-chevron {
max-width: 1.5rem;
}
Expand Down
4 changes: 4 additions & 0 deletions packages/ui/src/base/nav/nav.css
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@
white-space: nowrap;
}

.gl-nav-item-chevron-slot {
margin-inline-start: auto;
}

.gl-nav-item-addon,
.gl-nav-item-chevron {
max-width: 1.5rem;
Expand Down
36 changes: 36 additions & 0 deletions packages/ui/src/base/nav/nav.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,42 @@ export const ProviderRemoteControl: Story = {
},
};

export const SubNavChevronAlignment: Story = {
render: () => (
<GlNavProvider defaultOpen navId="sub-nav-chevron-alignment">
<GlCollapsibleNav aria-label="Sub-navigation chevron alignment">
<GlNavItem>
<GlNavButton><GlIcon name="settings" />Manage with icon</GlNavButton>
<GlSubNav>
<GlSubNavItem>
<GlSubNavButton href="/with-icon">Child with icon</GlSubNavButton>
</GlSubNavItem>
</GlSubNav>
</GlNavItem>
<GlNavItem>
<GlNavButton>Manage without icon</GlNavButton>
<GlSubNav>
<GlSubNavItem>
<GlSubNavButton href="/without-icon">Child without icon</GlSubNavButton>
</GlSubNavItem>
</GlSubNav>
</GlNavItem>
</GlCollapsibleNav>
</GlNavProvider>
),
play: async ({ canvas }) => {
const withIcon = canvas.getByRole("button", { name: "Manage with icon" });
const withoutIcon = canvas.getByRole("button", { name: "Manage without icon" });
const withIconChevron = within(withIcon).getByTestId("nav-item-chevron");
const withoutIconChevron = within(withoutIcon).getByTestId("nav-item-chevron");

await waitFor(() => {
expect(Math.round(withoutIconChevron.getBoundingClientRect().right))
.toBe(Math.round(withIconChevron.getBoundingClientRect().right));
});
},
};

export const InternalToggle: Story = {
render: () => (
<GlNavProvider defaultOpen navId="internal-toggle-navigation">
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/base/nav/nav.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ describe("GlSubNav", () => {

expect(markup).toContain("aria-expanded=\"false\"");
expect(markup).toContain("data-testid=\"nav-item-chevron\"");
expect(markup).toContain("gl-nav-item-chevron-slot");
expect(markup).toContain("aria-hidden=\"true\"");
expect(markup).not.toContain("defaultOpen");
});
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/base/nav/nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ function simpleTextLabel(nodes: ReactNode[]) {
function NavItemChevron() {
return (
<span
className={navSlotVariants()}
className={navSlotVariants({ className: "gl-nav-item-chevron-slot" })}
data-testid="nav-item-chevron"
aria-hidden="true">
<svg
Expand Down