-
Notifications
You must be signed in to change notification settings - Fork 65
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
Add helpertext to select #696
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ import { | |
compareAriaControls, | ||
stubEvent | ||
} from '../../../common/tests/support/test-helpers'; | ||
import HelperText from '../../../helper-text/index'; | ||
|
||
const harness = createHarness([ compareId, compareWidgetId, compareAriaControls ]); | ||
|
||
|
@@ -55,6 +56,7 @@ interface ExpectedOptions { | |
classes?: any[]; | ||
overrides?: any; | ||
focus?: boolean; | ||
helperText?: string; | ||
} | ||
|
||
const testOptions: any[] = [ | ||
|
@@ -208,7 +210,7 @@ const expectedSingle = function(useTestProperties = false, withStates = false, o | |
return vdom; | ||
}; | ||
|
||
const expected = function(selectVdom: any, { classes = [ css.root, null, null, null, null, null, null ], label = false, states, focus = false }: ExpectedOptions = {}) { | ||
const expected = function(selectVdom: any, { classes = [ css.root, null, null, null, null, null, null ], label = false, states, focus = false, helperText }: ExpectedOptions = {}) { | ||
return v('div', { | ||
key: 'root', | ||
classes | ||
|
@@ -223,7 +225,8 @@ const expected = function(selectVdom: any, { classes = [ css.root, null, null, n | |
required: undefined, | ||
forId: '' | ||
}, [ 'foo' ]) : null, | ||
selectVdom | ||
selectVdom, | ||
w(HelperText, { theme: undefined, text: helperText }) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need to have theme as a property here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we want to pass the actual theme through here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thats a test @agubler There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Urgh my bad, damn not using a top level test directory... that’s what I checked for 😂 |
||
]); | ||
}; | ||
|
||
|
@@ -240,6 +243,15 @@ registerSuite('Select', { | |
h.expect(() => expected(expectedNative())); | ||
}, | ||
|
||
'helperText'() { | ||
const h = harness(() => w(Select, { | ||
options: testOptions, | ||
useNativeElement: true, | ||
helperText: 'foo' | ||
})); | ||
h.expect(() => expected(expectedNative(), { helperText: 'foo' })); | ||
}, | ||
|
||
'custom properties'() { | ||
const h = harness(() => w(Select, { | ||
...testStateProperties, | ||
|
@@ -325,6 +337,11 @@ registerSuite('Select', { | |
h.expect(() => expected(expectedSingle())); | ||
}, | ||
|
||
'helperText'() { | ||
const h = harness(() => w(Select, { helperText: 'foo' })); | ||
h.expect(() => expected(expectedSingle(), { helperText: 'foo' })); | ||
}, | ||
|
||
'custom properties'() { | ||
const h = harness(() => w(Select, testStateProperties)); | ||
h.expect(() => expected(expectedSingle(true, true), { | ||
|
@@ -469,7 +486,8 @@ registerSuite('Select', { | |
onOptionSelect: noop | ||
}) | ||
]) | ||
]) | ||
]), | ||
w(HelperText, { theme: undefined, text: undefined}) | ||
])); | ||
}, | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you want to conditionally render the helper text widget? Something like
helperText ? w(HelperText, { theme, text: helperText }) : null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to render it at all times. The helpertext has both a root and a conditional text node. The reasoning behind this was to allow the consumer to theme it to reserve it's space if they wish in order to stop the UI jumping around if they helpertext shows / hides. In reality, it's best practise to always show a helperText for a widget that will be validated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, alright 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the render possess is cheap enough where you don't need to worry about that then