-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: export focusWithKeyboard, focusWithMouse & assert #23
Conversation
export const focusWithKeyboard = async(element) => { | ||
await sendKeys({ press: 'Escape' }); | ||
export async function focusWithKeyboard(element) { | ||
await sendKeys({ press: 'Shift' }); // Tab moves focus, Escape causes dismissible things to close |
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.
As hinted at with the comment, when using this in core Escape
was causing our dropdowns and dialogs to dismiss themselves. Core's copy uses Tab
which was also problematic since it moves focus around and was why our visual-diff copy used Escape
.
Shift
seems to be a safe option... we'll see though I guess.
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.
Haha and if not we'll just keep expanding the comment until we find something that works
@@ -1,2 +1,3 @@ | |||
export { aTimeout, defineCE, expect, html, nextFrame, oneEvent, waitUntil } from '@open-wc/testing'; | |||
export { assert, aTimeout, defineCE, expect, html, nextFrame, oneEvent, waitUntil } from '@open-wc/testing'; |
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.
Adding assert
as an export. Core no longer uses it but guaranteed other projects do.
|
||
export const focusWithKeyboard = async(element) => { |
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.
Does linting want the function
setup versus the const
setup, or just trying to match the style of the repo? Or is there an advantage of one over the other?
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.
This isn't linting related, it was more of a personal preference. TBH I'm not sure where or why the const
setup was introduced... maybe in the old visual-diff library and it got copied a bunch of places? If someone knows more about why we'd want one vs. the other, chime in!
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.
I'm not sure, I feel like we use the const
style randomly throughout core
, but it's not consistent. https://github.com/BrightspaceUI/core/blob/main/components/form/form-helper.js
https://github.com/BrightspaceUI/core/blob/main/helpers/gestures.js
And I just flip back and forth depending on what the file is already doing, so was mostly curious!
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.
Outside of using the one that's necessary based on their differences (this
, scope, hoisting), at the top level like this I'll usually use an arrow function for one-liners and regular function for anything longer.
🎉 This PR is included in version 0.7.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Core needs these, so adding them here & exporting. I'll delete core's copy once it's switched over to use this since it doesn't appear to be used outside of core.