Firefox v.101.0-2 download directory always changes to /run/user/1000/doc/

firefox is not taking into account that it is using the document portal and is blindly saving that portal directory as the assumed target that the user chose.

This is correct. Because portals patch the file selection dialogs, there is no way for Firefox to know the real path of a file the user selected. So this is in fact a fundamental design flaw in the way portals work, and there is no way for Firefox to take this into account. It is simply impossible for it to know the information it needs.

This bug also affects opening files and directories from the download manager. If you click “show in folder” or “open file” then the temporary download file/folder will be opened, if it still exists, otherwise nothing happens. If you then subsequently make changes to this file and same them, the changes will appear to have been lost when you subsequently open the file in its true location, and when the temporary directory gets cleaned up, they will truly be permanently lost. So this is a design flaw that causes data loss.

PS I reported this problem last year: Firefox snap can't open external applications - #8 by ali1234