* Removes the `tabindex` from the chip set and resets it back afterwards, allowing the * user to tab out of it. This prevents the set from capturing focus and redirecting * it back to the first chip, creating a focus trap, if it user tries to tab away.
()
| 184 | * it back to the first chip, creating a focus trap, if it user tries to tab away. |
| 185 | */ |
| 186 | protected _allowFocusEscape() { |
| 187 | const previous = this._elementRef.nativeElement.tabIndex; |
| 188 | |
| 189 | if (previous !== -1) { |
| 190 | // Set the tabindex directly on the element, instead of going through |
| 191 | // the data binding, because we aren't guaranteed that change detection |
| 192 | // will run quickly enough to allow focus to escape. |
| 193 | this._elementRef.nativeElement.tabIndex = -1; |
| 194 | |
| 195 | // Note that this needs to be a `setTimeout`, because a `Promise.resolve` |
| 196 | // doesn't allow enough time for the focus to escape. |
| 197 | setTimeout(() => (this._elementRef.nativeElement.tabIndex = previous)); |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | /** |
| 202 | * Gets a stream of events from all the chips within the set. |