Skip to content

Commit

Permalink
WIP(ui-selectable): talkBack selectable bug
Browse files Browse the repository at this point in the history
Closes: INSTUI-4207
  • Loading branch information
ToMESSKa committed Sep 18, 2024
1 parent 07840fb commit e2ba1de
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion packages/ui-selectable/src/Selectable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ class Selectable extends Component<SelectableProps> {
isShowingOptions: false
}

state = {
onFocus: false,
onSelect: false
}

_id = this.props.id || this.props.deterministicId!()
_listId = `${this._id}-list`
_descriptionId = `${this._id}-description`
Expand Down Expand Up @@ -154,6 +159,28 @@ class Selectable extends Component<SelectableProps> {
}
}

handleFocus = () => {
this.setState({
onFocus: true
})
}

handleSelect = () => {
this.setState({
onSelect: true
})
}

getMessage = () => {
const { onFocus, onSelect } = this.state
if (onFocus && !onSelect) {
/* eslint-disable no-console */
console.log('success') // Show success if only onFocus is triggered
}
/* eslint-disable no-console */
console.log('no success')
}

render() {
const {
isShowingOptions,
Expand Down Expand Up @@ -213,12 +240,13 @@ class Selectable extends Component<SelectableProps> {
}
},

getInputProps: ({ readOnly, ...rest } = {}) => {
getInputProps: ({ readOnly, onFocus, ...rest } = {}) => {
return {
role: 'combobox',
'aria-autocomplete': readOnly ? 'none' : 'both',
autoComplete: 'off',
readOnly,
onFocus: () => this.getMessage(),
...rest
}
},
Expand Down

0 comments on commit e2ba1de

Please sign in to comment.