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

Handle field placeholder when labels disabled #426

Merged
merged 5 commits into from
May 19, 2018
Merged

Handle field placeholder when labels disabled #426

merged 5 commits into from
May 19, 2018

Conversation

janowsiany
Copy link
Contributor

Solves bug raised in #421

@janowsiany janowsiany added the Type: Bug Bug reports and their fixes label May 15, 2018
@janowsiany janowsiany self-assigned this May 15, 2018
@janowsiany janowsiany requested a review from radekmie May 15, 2018 21:46
@janowsiany janowsiany changed the title Handle field placehodler when labels disabled Handle field placeholder when labels disabled May 15, 2018
@janowsiany
Copy link
Contributor Author

Should i put example of handling placeholder with GraphQLBridge extras?

@codecov
Copy link

codecov bot commented May 15, 2018

Codecov Report

Merging #426 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #426   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files         157    157           
  Lines        1396   1401    +5     
=====================================
+ Hits         1396   1401    +5
Impacted Files Coverage Δ
packages/uniforms/src/GraphQLBridge.js 100% <100%> (ø) ⬆️
packages/uniforms/src/JSONSchemaBridge.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8aa1e0d...6cca2a4. Read the comment docs.

@@ -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) {
Copy link
Contributor

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: '',
Copy link
Contributor

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,
Copy link
Contributor

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)) {
Copy link
Contributor

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.

@radekmie radekmie merged commit 928467e into master May 19, 2018
@radekmie radekmie deleted the issue-421 branch May 19, 2018 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Bug reports and their fixes
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants