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(FormStatus): fix stretch when used in Dropdown and Autocomplete #1618

Merged
merged 1 commit into from
Oct 10, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -2380,7 +2380,6 @@ legend.dnb-form-label {
.dnb-dropdown__inner {
display: inline-flex;
flex-direction: column;
align-items: flex-start;
margin: 0;
padding: 0;
width: auto;
Expand Down Expand Up @@ -2834,7 +2833,6 @@ legend.dnb-form-label {
.dnb-autocomplete__inner {
display: inline-flex;
flex-direction: column;
align-items: flex-start;
margin: 0;
padding: 0;
width: auto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
&__inner {
display: inline-flex;
flex-direction: column;
align-items: flex-start;

margin: 0;
padding: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
loadScss,
attachToBody, // in order to use document.activeElement properly
} from '../../../core/jest/jestSetup'
import { render } from '@testing-library/react'
import Component from '../Dropdown'
import {
mockImplementationForDirectionObserver,
Expand Down Expand Up @@ -200,6 +201,29 @@ describe('Dropdown component', () => {
).toBe('true')
})

it('shows form-status with correct classes', () => {
render(
<Component
skip_portal
no_animation
data={mockData}
status="status text"
status_state="warn"
status_props={{ stretch: true }}
/>
)

expect(
Array.from(document.querySelector('.dnb-form-status').classList)
).toEqual([
'dnb-form-status',
'dnb-form-status--warn',
'dnb-form-status__size--default',
'dnb-form-status--stretch',
'dnb-form-status--has-content',
])
})

it('will stay open when keep_open and a selection is made', () => {
const on_change = jest.fn()
const Comp = mount(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2142,7 +2142,6 @@ legend.dnb-form-label {
.dnb-dropdown__inner {
display: inline-flex;
flex-direction: column;
align-items: flex-start;
margin: 0;
padding: 0;
width: auto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
&__inner {
display: inline-flex;
flex-direction: column;
align-items: flex-start;

margin: 0;
padding: 0;
Expand Down
22 changes: 22 additions & 0 deletions packages/dnb-eufemia/src/components/input/__tests__/Input.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
axeComponent,
loadScss,
} from '../../../core/jest/jestSetup'
import { render } from '@testing-library/react'
import Component from '../Input'
import { format } from '../../number-format/NumberUtils'

Expand Down Expand Up @@ -329,6 +330,27 @@ describe('Input component', () => {
expect(Comp.find('.dnb-form-status__text').text()).toBe('status')
})

it('shows form-status with correct classes', () => {
render(
<Component
value="value"
status="status text"
status_state="warn"
status_props={{ stretch: true }}
/>
)

expect(
Array.from(document.querySelector('.dnb-form-status').classList)
).toEqual([
'dnb-form-status',
'dnb-form-status--warn',
'dnb-form-status__size--default',
'dnb-form-status--stretch',
'dnb-form-status--has-content',
])
})

it('has a disabled attribute, once we set disabled to true', () => {
const Comp = mount(<Component />)
Comp.setProps({
Expand Down