Skip to content

Commit

Permalink
fix: fix cascader placeholder internationalization (#19227)
Browse files Browse the repository at this point in the history
* fix: fix cascader placeholder

* Update index.tsx
  • Loading branch information
kagawagao authored and afc163 committed Oct 15, 2019
1 parent fb2bafb commit ab34970
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Expand Up @@ -952,7 +952,6 @@ exports[`Cascader should highlight keyword and filter when search in Cascader 1`
},
]
}
placeholder="Please select"
popupClassName=""
popupPlacement="bottomLeft"
popupVisible={true}
Expand Down Expand Up @@ -1250,7 +1249,6 @@ exports[`Cascader should render not found content 1`] = `
},
]
}
placeholder="Please select"
popupClassName=""
popupPlacement="bottomLeft"
popupVisible={true}
Expand Down Expand Up @@ -1578,7 +1576,6 @@ exports[`Cascader should show not found content when options.length is 0 1`] = `
},
]
}
placeholder="Please select"
popupClassName=""
popupPlacement="bottomLeft"
popupVisible={true}
Expand Down
11 changes: 11 additions & 0 deletions components/cascader/__tests__/index.test.js
Expand Up @@ -491,4 +491,15 @@ describe('Cascader', () => {
);
expect(popupWrapper.render()).toMatchSnapshot();
});

it('placeholder works correctly', () => {
const wrapper = mount(<Cascader options={[]} />);
expect(wrapper.find('input').prop('placeholder')).toBe('Please select');

const customPlaceholder = 'Custom placeholder';
wrapper.setProps({
placeholder: customPlaceholder,
});
expect(wrapper.find('input').prop('placeholder')).toBe(customPlaceholder);
});
});
3 changes: 1 addition & 2 deletions components/cascader/index.tsx
Expand Up @@ -216,7 +216,6 @@ function warningValueNotExist(list: CascaderOptionType[], fieldNames: FieldNames

class Cascader extends React.Component<CascaderProps, CascaderState> {
static defaultProps = {
placeholder: 'Please select',
transitionName: 'slide-up',
popupPlacement: 'bottomLeft',
options: [],
Expand Down Expand Up @@ -430,7 +429,7 @@ class Cascader extends React.Component<CascaderProps, CascaderState> {
prefixCls: customizePrefixCls,
inputPrefixCls: customizeInputPrefixCls,
children,
placeholder = locale.placeholder,
placeholder = locale.placeholder || 'Please select',
size,
disabled,
className,
Expand Down

0 comments on commit ab34970

Please sign in to comment.