Angular Aria Combobox and Listbox as hostDirectives mouse click functionality
Mantenedores costumam responder em até 1 dia
@ok7sai já está trabalhando nisso.
Desde 1/4/2026.
Avaliação
Esta issue ainda não foi avaliada.
Descrição
Which @angular/* package(s) are the source of the bug?
Don't known / other
Is this a regression?
No
Description
When using hostDirectives to implement a Combobox, mouse click will only open the combobox and not close it. Also the Listbox within will not register mouse clicks on Option components. Below is nearly the same example from the Docs, but using hostDirectives.
TS
import {
Combobox,
ComboboxInput,
ComboboxPopup,
ComboboxPopupContainer,
} from "@angular/aria/combobox";
import { Listbox, Option } from "@angular/aria/listbox";
import {
afterRenderEffect,
ChangeDetectionStrategy,
Component,
computed,
viewChild,
viewChildren,
} from "@angular/core";
import { OverlayModule } from "@angular/cdk/overlay";
@Component({
selector: "mww-select",
templateUrl: "./mww-select.html",
styleUrl: "./mww-select.css",
host: { ngCombobox: "", readonly: "" },
hostDirectives: [{ directive: Combobox, inputs: ["readonly"] }],
imports: [
ComboboxInput,
ComboboxPopup,
ComboboxPopupContainer,
Listbox,
Option,
OverlayModule,
],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class MwwSelect {
/** The combobox listbox popup. */
listbox = viewChild<Listbox<string>>(Listbox);
/** The options available in the listbox. */
options = viewChildren<Option<string>>(Option);
/** A reference to the ng aria combobox. */
combobox = viewChild<Combobox<string>>(Combobox);
/** The string that is displayed in the combobox. */
displayValue = computed(() => {
const values = this.listbox()?.values() || [];
if (values.length === 0) {
return "Select a label";
}
if (values.length === 1) {
return values[0];
}
return `${values[0]} + ${values.length - 1} more`;
});
/** The labels that are available for selection. */
labels = [
"Important",
"Starred",
"Work",
"Personal",
"To Do",
"Later",
"Read",
"Travel",
];
constructor() {
// Scrolls to the active item when the active option changes.
// The slight delay here is to ensure animations are done before scrolling.
afterRenderEffect(() => {
const option = this.options().find((opt) => opt.active());
setTimeout(
() => option?.element.scrollIntoView({ block: "nearest" }),
50,
);
});
// Resets the listbox scroll position when the combobox is closed.
afterRenderEffect(() => {
if (!this.combobox()?.expanded()) {
setTimeout(() => this.listbox()?.element.scrollTo(0, 0), 150);
}
});
}
}
Component HTML
<div #origin class="select">
<span class="combobox-label">
<span class="selected-label-text">{{ displayValue() }}</span>
</span>
<input aria-label="Label dropdown" placeholder="Select a label" ngComboboxInput />
<span class="example-arrow material-symbols-outlined" translate="no">arrow_drop_down</span>
</div>
<ng-template ngComboboxPopupContainer>
<ng-template [cdkConnectedOverlay]="{origin, usePopover: 'inline', matchWidth: true}"
[cdkConnectedOverlayOpen]="true">
<div class="example-popup-container">
<div ngListbox multi>
@for (label of labels; track label) {
<div ngOption [value]="label" [label]="label">
<span class="example-option-text">{{label}}</span>
<span class="example-option-check material-symbols-outlined" translate="no">check</span>
</div>
}
</div>
</div>
</ng-template>
</ng-template>
Usage HTML
<mww-select></mww-select>
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run ng version)
Angular CLI : 21.0.0
Angular : 21.0.0
Node.js : 22.18.0
Package Manager : npm 10.8.1
Operating System : win32 x64
┌───────────────────────────────────┬───────────────────┬───────────────────┐
│ Package │ Installed Version │ Requested Version │
├───────────────────────────────────┼───────────────────┼───────────────────┤
│ @angular-devkit/build-angular │ 21.0.0 │ ^21.0.0 │
│ @angular/animations │ 21.0.0 │ ^21.0.0 │
│ @angular/aria │ 21.0.0 │ ^21.0.0 │
│ @angular/cdk │ 21.0.0 │ ^21.0.0 │
│ @angular/cli │ 21.0.0 │ ^21.0.0 │
│ @angular/common │ 21.0.0 │ ^21.0.0 │
│ @angular/compiler │ 21.0.0 │ ^21.0.0 │
│ @angular/compiler-cli │ 21.0.0 │ ^21.0.0 │
│ @angular/core │ 21.0.0 │ ^21.0.0 │
│ @angular/forms │ 21.0.0 │ ^21.0.0 │
│ @angular/material │ 21.0.0 │ ^21.0.0 │
│ @angular/platform-browser │ 21.0.0 │ ^21.0.0 │
│ @angular/platform-browser-dynamic │ 21.0.0 │ ^21.0.0 │
│ @angular/router │ 21.0.0 │ ^21.0.0 │
│ rxjs │ 7.8.2 │ ^7.5.5 │
│ typescript │ 5.9.3 │ ^5.9.3 │
│ zone.js │ 0.15.1 │ ^0.15.1 │
└───────────────────────────────────┴───────────────────┴───────────────────┘
Anything else?
No response
- Linguagem predominante
- TypeScript
- Estrelas
- 25k
- Forks
- 6.8k
- Merge médio
- 1d 5h
- PRs com merge (30d)
- 67
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de angular/components
-
bug(aria/combobox): keys pressed back to back are lost; only the last one reaches the popupTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Abertaarea: aria/combobox gemini-triaged
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
angular/components#33973 ·
Mantenedores costumam responder em até 1 dia
-
bug(aria/combobox): ComboboxPopup throws NG0950 when destroyed before its first change detectionTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Abertaarea: aria/combobox gemini-triaged
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
angular/components#33972 ·
Mantenedores costumam responder em até 1 dia
-
bug(material/sort): hover hint arrow on an unsorted header shows the active sort direction, not the resulting direction after click.Talvez já em andamento @lekhmanrus assumiu há 12 dias. Abertaarea: material/sort P3
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
angular/components#33933 ·
Mantenedores costumam responder em até 1 dia
-
bug(mat-date-picker): month shown twice in date pickerTalvez já em andamento @PreethiPantangi assumiu há 29 dias. Abertaarea: material/datepicker P4
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
angular/components#33763 · 2 comentários · 3 reações ·
Mantenedores costumam responder em até 1 dia
-
Bug in table.scss footer cell height: unset instead of footer row height unsetTalvez já em andamento @minwookshin assumiu há 16 dias. Abertaarea: material/table P4
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
angular/components#33709 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
Todas as issues de angular/components
Issues semelhantes
-
area: app type: bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
ExpidetGames/code-reviewer#585 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 83/100
module-federation/core#5205 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 73/100
LanternOps/breeze#9392 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
engine-rs P3 review-deferral wasm
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 77/100
maniator/verticopolis#1154 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia