Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Breadcrumb): ensure focus state is not partially hidden #1949

Merged
merged 1 commit into from
Jan 26, 2023
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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/**
* UI lib Component Example
*
*/

import ComponentBox from 'dnb-design-system-portal/src/shared/tags/ComponentBox'
import Breadcrumb from '@dnb/eufemia/src/components/Breadcrumb'

export const BreadcrumbSingle = () => (
<ComponentBox data-visual-test="breadcrumb-single">
<Breadcrumb
onClick={() => {
console.log('Going back!')
}}
/>
</ComponentBox>
)

export const BreadcrumbMultipleData = () => (
<ComponentBox data-visual-test="breadcrumb-multiple">
{() => {
// You can also import pages from a store and only do a remapping
const pages = [
{
text: '',
href: '/',
},
{
text: 'UI Library',
href: '/uilib',
},
{
text: 'Components',
href: '/uilib/components',
},
{
text: 'Breadcrumbs',
href: '/uilib/components/breadcrumbs',
},
]

return <Breadcrumb data={pages} spacing />
}}
</ComponentBox>
)

export const BreadcrumbMultiple = () => (
<ComponentBox data-visual-test="breadcrumb-multiple-children">
<Breadcrumb spacing>
<Breadcrumb.Item
onClick={() => {
console.log('go home!')
}}
variant="home"
/>
<Breadcrumb.Item
text="Page item"
onClick={() => {
console.log('go to page 1')
}}
/>
<Breadcrumb.Item
text="Page item"
onClick={() => {
console.log('go to page 2')
}}
variant="current"
/>
</Breadcrumb>
</ComponentBox>
)

export const BreadcrumbVariants = () => (
<ComponentBox data-visual-test="breadcrumb-collapse">
{() => {
const pages = [
{
text: '',
href: '/',
},
{
text: 'UI Library',
href: '/uilib',
},
{
text: 'Components',
href: '/uilib/components',
},
]

return (
// Try changing variant here
<Breadcrumb variant="collapse" data={pages} spacing />
)
}}
</ComponentBox>
)

export const BreadcrumbCollapseOpen = () => (
<ComponentBox data-visual-test="breadcrumb-collapse-open">
{() => {
const pages = [
{
text: '',
href: '/',
},
{
text: 'UI Library',
href: '/uilib',
},
{
text: 'Components',
href: '/uilib/components',
},
]

return (
<Breadcrumb
variant="collapse"
data={pages}
isCollapsed={false}
spacing
/>
)
}}
</ComponentBox>
)
2 changes: 1 addition & 1 deletion packages/dnb-eufemia/jest.config.screenshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const config = require('./jest.config.js')
module.exports = {
...config,
...{
testRegex: 'screenshot.test.(js|tsx)$',
testRegex: 'screenshot.test.(js|ts|tsx)$',
globalSetup: './src/core/jest/jestPuppeteerSetup.js',
globalTeardown: './src/core/jest/jestPuppeteerTeardown.js',
testEnvironment: './src/core/jest/jestPuppeteerEnvironment.js',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,16 @@ describe('Breadcrumb screenshot', () => {
})
expect(screenshot).toMatchImageSnapshot()
})

it('have to match Breadcrumb focus state', async () => {
const screenshot = await testPageScreenshot({
selector: '[data-visual-test="breadcrumb-multiple"] .dnb-breadcrumb',
screenshotSelector:
'[data-visual-test="breadcrumb-multiple"] .dnb-breadcrumb .dnb-breadcrumb__bar',
simulateSelector:
'[data-visual-test="breadcrumb-multiple"] .dnb-breadcrumb__list .dnb-breadcrumb__item:nth-of-type(2) a',
simulate: 'focus',
})
expect(screenshot).toMatchImageSnapshot()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,6 @@ button.dnb-button::-moz-focus-inner {
.dnb-breadcrumb__animation {
display: flex;
flex-direction: column;
overflow: hidden;
transition: height 400ms var(--easing-default); }
.dnb-breadcrumb__animation .dnb-breadcrumb__item {
transition: transform 400ms var(--easing-default) calc(var(--delay) * 50ms);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
display: flex;
flex-direction: column;

overflow: hidden;
transition: height 400ms var(--easing-default);
}
&__animation &__item {
Expand Down