-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#FocusTrap for nested DynamicDialogs still not working #9329
Comments
hey! what is the issue can u please explain |
Hey!! problem is that when we open a dynamic dialog from a dynamic dialog then focus controls using tab key stuck on the 1st dialog. expected behavior should have been like focus on last open dynamic dialog |
Btw thanks for your reply |
This issue is also affecting the project I am working on. Trying to use the keyboard to tab through field when working on a Dynamic Dialog on-top of another Dynamic Dialog does not work. Trying to use the "FocusTrap" module on my second Dynamic Dialog does not address the issue. |
I have the same problem. Here is my workaround: export class FirstModalComponent {
constructor(
private dialogService: DialogService,
public dynamicDialogRef: DynamicDialogRef,
) {
}
public openSecondModal(): void {
// open the second modal
const secondModalRef = this.dialogService.open(SecodModalComponent);
// get DynamicDialogComponent instance for the current/first modal
const dynamicDialogComponent = this.dialogService.dialogComponentRefMap.get(this.dynamicDialogRef).instance;
// unbind tab/esc buttons listeners
dynamicDialogComponent.unbindGlobalListeners();
// when the second modal is closed/destroyed then
secondModalRef.onDestroy.pipe(first()).subscribe(() => {
// reinitialize the first modal
dynamicDialogComponent.moveOnTop(); // we need this for properly Esc button handler
dynamicDialogComponent.bindGlobalListeners(); // bind tab/esc buttons listeners
dynamicDialogComponent.focus(); // apply [autofocus] if any
});
}
} |
What is the first() thing you're calling in the pipe? I'm trying your workaround but this isn't working for me. Wait, apparently it's part of rxjs. But this part:
is coming back as undefined for me. |
As I mentioned in the comment, it is to "get DynamicDialogComponent instance for the current/first modal", without this line, we can't do all the things below. Because |
Same problem |
I also have the same problem |
To work you need to add the DialogService into app.module providers |
I am also experiencing the tab problem - in a dynamic dialog, opened from a dynamic dialog, all tabbing wants to go to the close button (X). If I turn that off, all tabbing goes to the first input control. |
was this problem resolved? |
not found any solution that's why I avoid nested dialog solution in my application |
@cagataycivici Thanks in advance |
Any updates on this issue? |
I'm having the same problem with pressing enter or space keys |
I found a posible solution, apply when open a DynamicDialog inside another DynamicDialog export class DynamicDialog2 implements OnInit { |
Unfortunatly, this workaround does not work for me. Any updates on this issue ? |
please help us! |
The workaround did not work for me neither. But I've found a solution. Here is the relevant part : @Component({
templateUrl: './first-dialog.component.html',
providers: [DialogService]
})
export class FirstDialogComponent {
constructor(
private refDialogComponent: DynamicDialogComponent,
private dialogService: DialogService
) { }
public openSecondDialog(): void {
this.refDialogComponent.unbindDocumentKeydownListener();
const subref = this.dialogService.open(SecondDialogComponent);
subref.onDestroy.pipe(
take(1),
tap(() => this.refDialogComponent.bindDocumentKeydownListener())
).subscribe();
}
} The trick is to get a reference to the nearest |
Hi, So sorry for the delayed response! Improvements have been made to many components recently, both in terms of performance and enhancement. Therefore, this improvement may have been developed in another issue ticket without realizing it. You can check this in the documentation. If there is no improvement on this, can you reopen the issue so we can include it in our roadmap? Best Regards, |
Hi, The problem is still not solved with the latest version of PrimeNG 14.2.1 |
Just discovered this issue in my app, looking for a fix. Thanks @mselerin for pushing the fix and workaround! |
Hi @mertsincan, @cagataycivici |
I created this service, all you need is to just open every dialog with this. import { Injectable, Type } from '@angular/core';
import {
DialogService,
DynamicDialogComponent,
DynamicDialogConfig,
DynamicDialogRef,
} from 'primeng/dynamicdialog';
import { first } from 'rxjs/operators';
@Injectable({
providedIn: 'root',
})
export class TabbedDialogService {
constructor(private dialogService: DialogService) {}
currentDialogRef: DynamicDialogRef | null = null;
open(
componentType: Type<any>,
config: DynamicDialogConfig
): DynamicDialogRef {
let currentDialogComponent: DynamicDialogComponent | undefined;
if (this.currentDialogRef) {
currentDialogComponent = this.dialogService.dialogComponentRefMap.get(
this.currentDialogRef
)?.instance;
currentDialogComponent?.unbindGlobalListeners();
}
const lastDialogRef = this.currentDialogRef;
const dialogRef = this.dialogService.open(componentType, config);
this.currentDialogRef = dialogRef;
dialogRef.onDestroy.pipe(first()).subscribe(() => {
// reinitialize the first modal
if (currentDialogComponent) {
currentDialogComponent.moveOnTop(); // we need this for properly Esc button handler
currentDialogComponent.bindGlobalListeners(); // bind tab/esc buttons listeners
currentDialogComponent.focus(); // apply [autofocus] if any
}
this.currentDialogRef = lastDialogRef;
});
return dialogRef;
}
} |
@djay1977 I have the same problem, but DynamicDialogComponent is a component, that is, I can't inject a component into a class, is there any solution for this? |
the solution is here : #12039 |
for me it still doesn't work :( (version 16.5.0) |
En la versión 17.3.3 yo hice lo siguiente : 1 .Desde MenuComponent abro el primer dialog que tiene el componente FloatRequestsComponent : ` public openRequestsFloatingModal() : void {
|
Tab keys not working when i open dynamic dialog from another dynamic dialog, it stuck on close button so if i focus on control by using mouse keys and then i press tab key it focus again close button. I am using 9.1.5-lts version
The text was updated successfully, but these errors were encountered: