-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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/issue 5693 firefox focus trap #11601
Changes from 6 commits
39bc785
e15b05f
f9856ed
0395ac4
9eca9bf
140b4c3
2297665
48c7787
8b769e0
89bfd27
088b011
667dec6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,6 +137,32 @@ class URLInput extends Component { | |
// If the suggestions are not shown or loading, we shouldn't handle the arrow keys | ||
// We shouldn't preventDefault to allow block arrow keys navigation | ||
if ( ! showSuggestions || ! posts.length || loading ) { | ||
// This switch statement corrects a bug in Windows Firefox | ||
switch ( event.keyCode ) { | ||
case UP: { | ||
// If the caret is not in position 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment is pretty much describing the if condition below, which is pretty easy to read. But the point here is the caret should be moved to the beginning if it's not there when |
||
if ( 0 !== event.target.selectionStart ) { | ||
event.stopPropagation(); | ||
tofumatt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
event.preventDefault(); | ||
|
||
// Set the input caret to position 0 | ||
event.target.setSelectionRange( 0, 0 ); | ||
} | ||
break; | ||
} | ||
case DOWN: { | ||
// If the caret is not in the last position | ||
if ( this.props.value.length !== event.target.selectionStart ) { | ||
event.stopPropagation(); | ||
event.preventDefault(); | ||
|
||
// Set the inpit caret to the last position | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: should be "input" |
||
event.target.setSelectionRange( this.props.value.length, this.props.value.length ); | ||
} | ||
break; | ||
} | ||
} | ||
|
||
return; | ||
} | ||
|
||
|
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.
Is there anymore context for this bug? What causes it? Is there a link explaining what's happening here or what the bug is?
It would be helpful for future developers to get a bit more info here 😄
The info you wrote up in the original issue (
#5693 (comment)) was handy, so even including that or parts of it (and then linking to the comment for more context) would be great!