-
Notifications
You must be signed in to change notification settings - Fork 841
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EuiRange/EuiDualRange] Add alert icon when
isInvalid
and `showInpu…
…t` (#6704) * [EuiFormControlLayoutDelimited] nit: fix `delimiter` spelling * [EuiFormControlLayoutDelimited] Change default delimiter to an icon instead of text - to more correctly matches the current Figma designs + add a screen reader label * [EuiFormControlLayoutDelimited] Add better `isInvalid` styling - color arrow + extend line under arrow and icons + fix background colors of icons * [EuiDualRange] Fix buggy styling when `isInvalid` and `showInput="inputWithPopover"` - the input was rendering the padding offset for the invalid icon, without actually rendering said icons (due to `controlOnly` prop) * [EuiFieldNumber] Fix browser invalid state not showing an icon or setting `aria-invalid` Browsers natively set their own custom `validity` based on min/max/value/step/etc - we should hook into these and extend them (as opposed to overriding them) + switch Jest tests from Enzyme to RTL while here * [EuiRange/EuiDualRange] Improve UX of input widths on EuiRange/EuiDualRange - account for `invalid` icon (which now automatically displays for out of range inputs) - dynamically adjust width based on # of characters in actual input - adjust width affordances based on `compressed` - width changes are especially a readability improvement in Firefox * changelog * Revert horizontal padding on delimited icons - after playing more with date range picker as well as a broader variety of delimited inputs, this change was too specific to EuiDualRange * snapshot
- Loading branch information
Showing
19 changed files
with
469 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
/// <reference types="cypress" /> | ||
/// <reference types="cypress-real-events" /> | ||
/// <reference types="../../../../cypress/support" /> | ||
|
||
import React from 'react'; | ||
import { EuiFieldNumber } from './field_number'; | ||
|
||
describe('EuiFieldNumber', () => { | ||
describe('isNativelyInvalid', () => { | ||
const checkIsValid = () => { | ||
cy.get('[aria-invalid="true"]').should('not.exist'); | ||
cy.get('.euiFormControlLayoutIcons').should('not.exist'); | ||
}; | ||
const checkIsInvalid = () => { | ||
cy.get('[aria-invalid="true"]').should('exist'); | ||
cy.get('.euiFormControlLayoutIcons').should('exist'); | ||
}; | ||
|
||
it('when the value is not a valid number', () => { | ||
cy.mount(<EuiFieldNumber />); | ||
checkIsValid(); | ||
cy.get('input').click().realType('-.'); | ||
checkIsInvalid(); | ||
}); | ||
|
||
it('sets invalid state when the value is less than the passed min', () => { | ||
cy.mount(<EuiFieldNumber min={0} />); | ||
checkIsValid(); | ||
cy.get('input').click().type('-10'); | ||
checkIsInvalid(); | ||
}); | ||
|
||
it('sets invalid state when the value is greater than the passed max', () => { | ||
cy.mount(<EuiFieldNumber max={100} />); | ||
checkIsValid(); | ||
cy.get('input').click().type('101'); | ||
checkIsInvalid(); | ||
}); | ||
|
||
it('sets invalid state when the value is not a valid step', () => { | ||
cy.mount(<EuiFieldNumber step={3} />); | ||
checkIsValid(); | ||
cy.get('input').click().type('2'); | ||
checkIsInvalid(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.