-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
fix: token warning modal stealing focus across frame boundaries #1205
fix: token warning modal stealing focus across frame boundaries #1205
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/uniswap/uniswap-interface/nahjfj863 |
This is very interesting--is it better fixed in the browser though? Should a child iframe be able to steal focus or blur inputs on the parent page? It seems like a good thing you can't tab outside of the modal while on the Uniswap interface. |
style={props} | ||
onDismiss={onDismiss} | ||
initialFocusRef={initialFocusRef} | ||
dangerouslyBypassFocusLock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs on this explicitly say that you should have some replacement focus lock if you enable this, but I don't see any replacement in this PR.
IIUC, the browser solution is to disallow the iframe from being able to programmatically set focus at all. Essentially this means that Uniswap should not depend on its ability to control focus for disabling page content. Instead it should disable fields in the app and/or use an overlay. |
IMO it should not, but evidently it is possible in some browsers. Afaik there isn't a way to prevent this from the parent page. Probably need to do what @MicahZoltu suggested i.e. disabling all inputs in uniswap-interface when the modal is open. Is this approach okay? @moodysalem |
Wdym by an overlay? I do not like the idea of disabling all other inputs on the page when a modal is open. It will either be mutating the dom of many components outside of react and is likely to break, or require changing tons of components The browser solution breaks the reach dialog's focus solution to tabbing outside the modal, and that's fine with me--it's not required. I am pretty sure the browser should fix it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
I'm not a huge fan either, but I don't think there is another option if you want the iframe widget to work correctly and not inappropriately interfere with the hosting page. If you do nothing, people using the iframe have two choices:
I agree that it increases complexity quite a bit. I would not be worried about DOM updates since most (all) of the changes won't trigger a re-layout, just some non resizing style changes. Component updates aren't that expensive (on this order of magnitude) as long as they don't trigger a relayout. I suspect you can mitigate the complexity quite a bit with a good framework (e.g., React).
From what I have seen, no browser considers this a bug. I can appreciate one disagreeing on this, but I think Uniswap should work in the real world, not in a hypothetical future that doesn't align with current trajectory for reality. |
We need to set crossFrame to false on the underlying focus lock that reach dialog is rendering |
@moontools-hyperion are you able to add a replacement focus lock to the Modal component that has crossFrame set to false? |
Any updates on this ? |
The better fix is described in the above comment (disable only cross frame focus lock) and we would accept any pull request that implements it |
Hi @moodysalem, I've created a PR for this at #1326 |
The token warning modal in the Uniswap interface, when embedded in an iframe on a parent page, steals focus from the parent window. This prevents users from interacting with input elements in the parent window.
Simple example of issue:
https://jsfiddle.net/26cms93e/
Steps to reproduce:
This issue is also present on other DEX data explorer sites. This PR fixes the issue described above.