Skip to content

Commit

Permalink
fix(PhoneNumber): show read outline on both fields in error state (#3196
Browse files Browse the repository at this point in the history
)
  • Loading branch information
tujoworker authored Jan 9, 2024
1 parent b856a46 commit 16ed821
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ export const Disabled = () => {

export const Error = () => {
return (
<ComponentBox scope={{ FormError }}>
<ComponentBox
scope={{ FormError }}
data-visual-test="phone-number-error"
>
<Field.PhoneNumber
value="007"
label="Label text"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1338,12 +1338,14 @@ exports[`Input scss have to match default theme snapshot 1`] = `
color: var(--color-fire-red);
}
.dnb-input__status--error.dnb-input:not([data-input-state=focus]):not(:hover) .dnb-input__shell {
--input-border-color: transparent;
--border-color: var(--color-fire-red);
--border-width: 0.0625rem;
box-shadow: 0 0 0 var(--border-width) var(--border-color);
border-color: transparent;
}
.dnb-input__status--error.dnb-input[data-input-state=focus] .dnb-input__shell, .dnb-input__status--error.dnb-input:not([data-input-state=disabled]) .dnb-input__shell:hover, .dnb-input__status--error.dnb-input:not([data-input-state=disabled]):hover .dnb-input__shell {
--input-border-color: var(--color-fire-red);
--border-color: var(--color-fire-red);
--border-width: var(--input-border-width--focus);
box-shadow: 0 0 0 var(--border-width) var(--border-color);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@
}
&__status--error#{&}:not([data-input-state='focus']):not(:hover)
&__shell {
--input-border-color: transparent;
@include fakeBorder(var(--color-fire-red));
}
&__status--error#{&}[data-input-state='focus'] &__shell,
&__status--error#{&}:not([data-input-state='disabled']) &__shell:hover,
&__status--error#{&}:not([data-input-state='disabled']):hover &__shell {
--input-border-color: var(--color-fire-red);
@include fakeBorder(
var(--color-fire-red),
var(--input-border-width--focus)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ function PhoneNumber(props: Props) {
}
data={dataRef.current}
value={countryCodeRef.current}
status={error ? 'error' : undefined}
disabled={disabled}
on_focus={onFocusHandler}
on_blur={handleBlur}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ describe.each(['ui'])('PhoneNumber for %s', (themeName) => {
})
expect(screenshot).toMatchImageSnapshot()
})

it('have to match with error', async () => {
const screenshot = await makeScreenshot({
selector: '[data-visual-test="phone-number-error"]',
})
expect(screenshot).toMatchImageSnapshot()
})
})

describe('PhoneNumber', () => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 16ed821

Please sign in to comment.