The commits in your screenshots are old. We did land a fix for this before the OP was created, but it hasn’t been working too well on Firefox.
I have another PR in the works at DEV: Consolidate mobile positioning strategies on mobile and iPad by pmusaraj · Pull Request #30241 · discourse/discourse · GitHub, we are currently testing those changes and I hope we can merge the PR shortly.