-
-
Notifications
You must be signed in to change notification settings - Fork 246
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
Handle field placeholder when labels disabled #426
Conversation
Should i put example of handling placeholder with GraphQLBridge extras? |
Codecov Report
@@ Coverage Diff @@
## master #426 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 157 157
Lines 1396 1401 +5
=====================================
+ Hits 1396 1401 +5
Continue to review full report at Codecov.
|
@@ -137,6 +137,12 @@ export default class GraphQLBridge extends Bridge { | |||
ready.label = ''; | |||
} | |||
|
|||
if (props.placeholder === true && extra.placeholder) { | |||
ready.placeholder = extra.placeholder; | |||
} else if (props.placeholder !== undefined && !props.placeholder) { |
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'd rather check for false
and null
explicitly here.
it('works with placeholder (falsy)', () => { | ||
expect(bridgeI.getProps('id', {placeholder: null})).toEqual({ | ||
label: 'Post ID', | ||
placeholder: '', |
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.
Test for placeholder === true
and extra.placeholder === undefined
is missing.
const ready = { | ||
allowedValues, | ||
...(fieldType === 'number' ? {decimal: true} : {}), | ||
options: opts || options, | ||
label: label === true ? fieldName.charAt(0).toUpperCase() + fieldName.slice(1).toLowerCase() : label || '', | ||
label: label === true ? fieldNameCapitalized : label || '', | ||
placeholder: placeholder === true ? fieldNameCapitalized : placeholder || 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.
There's no need for || undefined
.
@@ -139,7 +139,7 @@ export default class GraphQLBridge extends Bridge { | |||
|
|||
if (props.placeholder === true && extra.placeholder) { | |||
ready.placeholder = extra.placeholder; | |||
} else if (props.placeholder !== undefined && !props.placeholder) { | |||
} else if (props.placeholder !== undefined && (props.placeholder === false || props.placeholder === 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.
Now the left part of &&
is not needed. Please remove it and we are all set.
Solves bug raised in #421