-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Open
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: cdk/dialogarea: material/autocomplete
Description
Is this a regression?
- Yes, this behavior used to work in the previous versionTo pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
The previous version in which this bug was not present was
See: #30254, it was present in 18 version.
Description
Demo: https://github.com/lopatnov/autocomplete-issue
Reproduction
StackBlitz link: I don't use StackBlitz, don't know how to upload demo here.
Steps to reproduce:
- Open dialog with some elements, to have scroll in the dialog
- Open Autocomplete items
- Scroll down dialog scroll and you will see issue
Expected Behavior
Options of Autocomplete should stay below autocomplete, as it was opened. They don't need to move with dialog scrollbar.
Actual Behavior
When dialog scrollbar moves, then autocomplete options also moves.
Environment
- Angular: 19.1.0
- CDK/Material: 19.1.1
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): Windows
Metadata
Metadata
Assignees
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: cdk/dialogarea: material/autocomplete
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
wagnermaciel commentedon Feb 24, 2025
Hi @lopatnov, unfortunately I cannot download and run your repo because of potential security concerns. Could you try recreating the demo on stackblitz? Here is a starting point you can use:
https://stackblitz.com/run?file=.gitignore
lopatnov commentedon Feb 27, 2025
I'll try to figure out how to do this today after work. Pay attention to this comment please: #30254 (comment) I showed the difference for mat-select and mat-autocomplete and why for mat-select it doesn't working and for mat-autocomplete this issue working. The difference is in backdrop, that for mat-select exists.
lopatnov commentedon Feb 27, 2025
@wagnermaciel , I tried it now. It's first time I'm trying stackblitz. Try this link: https://stackblitz.com/~/github.com/lopatnov/autocomplete-issue. Does it working?
lopatnov commentedon Feb 27, 2025
Detail process in image how to reproduce:
wagnermaciel commentedon Feb 27, 2025
Yeah, the stackblitz worked - thanks for putting that together!
A temporary workaround would be to close the autocomplete when you scroll the dialog content
For some reason I can't fork the stackblitz you shared but here is how you could accomplish this:
lopatnov commentedon Feb 28, 2025
@wagnermaciel , Why is there a backdrop for mat-select, but not for mat-autocomplete? Why do I need to use a workaround for this? It's just a bug and I hope it will be fixed.
lopatnov commentedon Feb 28, 2025
Also, try to move dialog window. In that way options will be on the same place and this is the same issue
lopatnov commentedon Feb 28, 2025
Added second case, try to move dialog window when autocomplete was opened:
wagnermaciel commentedon Feb 28, 2025
I didn't author these components so I don't know why. If you'd like to read through the code, I'm sure you'll be able to uncover why these were written this way
The timeline for a fix heavily depends on how breaking a change it would be to land the fix. If someone can identify a fix that's backwards compatible that would be great, but changes to DOM structure are notoriously difficult to land because the fix would break people's existing applications. Unless more people start running into this issue, I'm not sure how likely it will that this gets prioritized.
lopatnov commentedon Mar 1, 2025
@wagnermaciel The problem is in overlays. I suggested changing the overlay in mat-select and mat-autocomlete a few years ago, but I was told that they are significantly different from the existing ones and that the idea is to reuse the code as much as possible. But what's the point of reusing the code as much as possible if it is initially incorrect? Nobody makes options for such slect elements like in dialog boxes uses. Relative and absolute positioning and a blur event are used to make options disappear. There is no need to invent anything else there. And now I’m faced with the fact that for someone on the project this turns out to be a problem.
And if I add to the CDK such overlays that you don’t have yet and such selects that you don’t have, will you consider such changes or shouldn’t even try?
hasBackdrop
option #30631