diff --git a/cypress/e2e/select.spec.js b/cypress/e2e/select.spec.js index f3dcf68ce8..a62921efcf 100644 --- a/cypress/e2e/select.spec.js +++ b/cypress/e2e/select.spec.js @@ -80,6 +80,20 @@ describe('Select', () => { cy.get('.semi-select-option').eq(3).should('have.text', 'Xigua'); }); + it('blur', () => { + cy.visit('http://127.0.0.1:6006/iframe.html?path=/story/select--select-on-blur-on-focus', { + onBeforeLoad(win) { + cy.stub(win.console, 'log').as('consoleLog'); + }, + }); + + cy.get('.semi-select-selection').eq(0).click(); + cy.get('.semi-select-option').eq(0).click(); + cy.get('body').click('right'); + cy.get('@consoleLog').should('be.calledWith', 'onBlur'); + + }); + // it('ellipsisTrigger', () => { // cy.visit('http://127.0.0.1:6006/iframe.html?path=/story/select--fix-1560'); diff --git a/packages/semi-foundation/select/foundation.ts b/packages/semi-foundation/select/foundation.ts index 04fdf769fc..d1cac2c4a8 100644 --- a/packages/semi-foundation/select/foundation.ts +++ b/packages/semi-foundation/select/foundation.ts @@ -363,6 +363,7 @@ export default class SelectFoundation extends BaseFoundation { this.close(e); this._notifyBlur(e); this._adapter.updateFocusState(false); + this._adapter.unregisterClickOutsideHandler(); }); } @@ -383,7 +384,6 @@ export default class SelectFoundation extends BaseFoundation { this._adapter.setIsFocusInContainer(false); // this.unBindKeyBoardEvent(); // this._notifyBlur(e); - this._adapter.unregisterClickOutsideHandler(); // this._adapter.updateFocusState(false); const isFilterable = this._isFilterable(); diff --git a/packages/semi-ui/select/_story/select.stories.jsx b/packages/semi-ui/select/_story/select.stories.jsx index 069e2df506..00c61ad3cd 100644 --- a/packages/semi-ui/select/_story/select.stories.jsx +++ b/packages/semi-ui/select/_story/select.stories.jsx @@ -2207,11 +2207,13 @@ const BlurDemo = () => { const onBlur = (value, e) => { console.log(value); console.log(e); + console.log('onBlur'); }; const onFocus = (value, e) => { console.log(value); console.log(e); + console.log('onFocus'); }; return ( @@ -2230,6 +2232,24 @@ const BlurDemo = () => { Germany France +
+
+
+ ); };