* Finds the next appropriate chip to move focus to, * if the currently-focused chip is destroyed.
()
| 311 | * if the currently-focused chip is destroyed. |
| 312 | */ |
| 313 | protected _redirectDestroyedChipFocus() { |
| 314 | if (this._lastDestroyedFocusedChipIndex == null) { |
| 315 | return; |
| 316 | } |
| 317 | |
| 318 | if (this._chips.length) { |
| 319 | const newIndex = Math.min(this._lastDestroyedFocusedChipIndex, this._chips.length - 1); |
| 320 | const chipToFocus = this._chips.toArray()[newIndex]; |
| 321 | |
| 322 | if (chipToFocus.disabled) { |
| 323 | // If we're down to one disabled chip, move focus back to the set. |
| 324 | if (this._chips.length === 1) { |
| 325 | this.focus(); |
| 326 | } else { |
| 327 | this._keyManager.setPreviousItemActive(); |
| 328 | } |
| 329 | } else { |
| 330 | chipToFocus.focus(); |
| 331 | } |
| 332 | } else { |
| 333 | this.focus(); |
| 334 | } |
| 335 | |
| 336 | this._lastDestroyedFocusedChipIndex = null; |
| 337 | } |
| 338 | } |
no test coverage detected