This is a problem I am hitting for a long time but I am unsure about if other people can reproduce.
Simply try to go to gmail account, choose to create a new mail and try to attach a file.
Sometimes the first time it works, but if you click on cancel and retry, file chooser is always opened without getting the focus.
I am now running under Gnome 41 and it happens the same with X or wayland. On the other hand firefox and epiphany work properly. I have also tried to use Chrome in Incognito mode, but I have the same issue :/
The same issue happens with a newly created user account and fresh configuration for everything
Thanks for your guidance
I tested with KDE Plasma, and the KDialog window has focus when I add an attachment in Gmail.
Please open an upstream bug at https://crbug.com.