Skip to content

Commit

Permalink
fix(single select): blur when actually blurring the input
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammer5 committed Nov 1, 2023
1 parent de02caf commit 931feac
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 0 additions & 7 deletions components/select/src/select/input-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const InputWrapper = ({
dataTest,
onToggle,
children,
tabIndex,
error,
warning,
valid,
Expand All @@ -29,7 +28,6 @@ const InputWrapper = ({
<div
className={classNames}
onClick={onToggle}
tabIndex={tabIndex}
ref={inputRef}
data-test={dataTest}
>
Expand Down Expand Up @@ -97,14 +95,9 @@ const InputWrapper = ({
)
}

InputWrapper.defaultProps = {
tabIndex: '0',
}

InputWrapper.propTypes = {
dataTest: PropTypes.string.isRequired,
inputRef: PropTypes.object.isRequired,
tabIndex: PropTypes.string.isRequired,
onToggle: PropTypes.func.isRequired,
children: PropTypes.element,
className: PropTypes.string,
Expand Down
4 changes: 3 additions & 1 deletion components/select/src/select/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,17 @@ export class Select extends Component {

return (
<div
tabIndex={disabled ? '-1' : tabIndex}
className={className}
ref={this.selectRef}
onFocus={this.onFocus}
onBlur={this.onOutsideClick}
onKeyDown={this.onKeyDown}
data-test={dataTest}
>
<InputWrapper
onToggle={this.onToggle}
inputRef={this.inputRef}
tabIndex={disabled ? '-1' : tabIndex}
error={error}
warning={warning}
valid={valid}
Expand Down Expand Up @@ -219,6 +220,7 @@ export class Select extends Component {

Select.defaultProps = {
dataTest: 'dhis2-uicore-select',
tabIndex: '0',
}

Select.propTypes = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import '../common/index.js'
import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps'
import { Given, When, Then, After } from 'cypress-cucumber-preprocessor/steps'

After(() => {
cy.window().then((win) => {
win.onChange.reset()
win.onFocus.reset()
win.onBlur.reset()
})
})

Given('a SingleSelect with onBlur handler is rendered', () => {
cy.visitStory('SingleSelect', 'With onBlur')
Expand Down

0 comments on commit 931feac

Please sign in to comment.