diff --git a/components/cascader/__tests__/__snapshots__/index.test.js.snap b/components/cascader/__tests__/__snapshots__/index.test.js.snap index d6ecfaddaf..c8d21910c6 100644 --- a/components/cascader/__tests__/__snapshots__/index.test.js.snap +++ b/components/cascader/__tests__/__snapshots__/index.test.js.snap @@ -349,6 +349,74 @@ exports[`Cascader can be selected 3`] = ` `; +exports[`Cascader have a notFoundContent that fit trigger input width 1`] = ` +
+
+
+
    + +
+
+
+
+`; + exports[`Cascader popup correctly when panel is hidden 1`] = `
{ mount(); }).not.toThrow(); }); + + // https://github.com/ant-design/ant-design/issues/18176 + it('have a notFoundContent that fit trigger input width', () => { + const wrapper = mount(); + const popupWrapper = mount( + wrapper + .find('Trigger') + .instance() + .getComponent(), + ); + expect(popupWrapper.render()).toMatchSnapshot(); + }); }); diff --git a/components/cascader/index.tsx b/components/cascader/index.tsx index 9f0222acdf..87b48ba24b 100644 --- a/components/cascader/index.tsx +++ b/components/cascader/index.tsx @@ -496,12 +496,12 @@ class Cascader extends React.Component { ]); let { options } = props; + const names: FilledFieldNamesType = getFilledFieldNames(this.props); if (options && options.length > 0) { if (state.inputValue) { options = this.generateFilteredOptions(prefixCls, renderEmpty); } } else { - const names: FilledFieldNamesType = getFilledFieldNames(this.props); options = [ { [names.label]: notFoundContent || renderEmpty('Cascader'), @@ -519,7 +519,7 @@ class Cascader extends React.Component { const dropdownMenuColumnStyle: { width?: number; height?: string } = {}; const isNotFound = - (options || []).length === 1 && options[0].value === 'ANT_CASCADER_NOT_FOUND'; + (options || []).length === 1 && options[0][names.value] === 'ANT_CASCADER_NOT_FOUND'; if (isNotFound) { dropdownMenuColumnStyle.height = 'auto'; // Height of one row. } @@ -554,7 +554,7 @@ class Cascader extends React.Component { value={state.inputValue} disabled={disabled} readOnly={!showSearch} - autoComplete={inputProps.autoComplete || "off"} + autoComplete={inputProps.autoComplete || 'off'} onClick={showSearch ? this.handleInputClick : undefined} onBlur={showSearch ? this.handleInputBlur : undefined} onKeyDown={this.handleKeyDown} diff --git a/package.json b/package.json index 6dee06ae4f..b0cfa12487 100644 --- a/package.json +++ b/package.json @@ -144,6 +144,7 @@ "jest": "^24.8.0", "jsdom": "^15.1.1", "jsonml.js": "^0.1.0", + "less": "~3.9.0", "logrocket": "^1.0.0", "logrocket-react": "^3.0.0", "lz-string": "^1.4.4",