-
Notifications
You must be signed in to change notification settings - Fork 3.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
Ctrl+F to set focus on the search bar #6325
Ctrl+F to set focus on the search bar #6325
Conversation
Thanks for the contribution! Below are some guidelines Cypress uses when doing PR reviews.
PR Review ChecklistIf any of the following requirements can't be met, leave a comment in the review selecting 'Request changes', otherwise 'Approve'. User Experience
Functionality
Maintainability
Quality
Internal
|
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.
We will need some tests written to verify this new behavior.
To run the tests for the Desktop-GUI:
- within
cypress
root, runnpm i
- cd to
cypress/packages/desktop-gui
and runnpm run watch
- In
cypress/packages/desktop-gui
runnpm run cypress:open
- click on the test you're writing to run it within Cypress
Instructions for running the desktop-gui
tests can always be found here: https://github.com/cypress-io/cypress/blob/develop/packages/desktop-gui/README.md
The tests for this PR should be in this file specifically, involving searching the specs list: https://github.com/cypress-io/cypress/blob/develop/packages/desktop-gui/cypress/integration/specs_list_spec.js#L282:L282
@jennifer-shehane thanks for all the information. I have tried to add the following tests: it('sets focus on search filters if user presses Ctrl + F', () => {
cy.get('.filter').type('{ctrl}F')
cy.get('.filter').should('to.be.focus')
}) It passes correctly, but when I tried to
Do I need to add this new test to a spec I also closed the branch by mistake 😱 , I have reopened it.. sorry about that... |
@jennifer-shehane I have tried adding the test in different places within the I have attached a screenshot below showing that all tests passed properly: |
@Manuel-Suarez-Abascal The warning is indicating that you have a But, if this is not the case, I think that there is an issue where this Pass the |
…scal/cypress into issue-6229
@jennifer-shehane thanks! It worked like a charm! I have pushed my latest changes. |
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.
Shouldn't this be Meta + F
? I instantly tried Meta + F
(command
on mac) because that is what inherently works in most browsers/applications to search for text and thought it wasn't working, but this is coded as Ctrl + f
, which I don't think is a great experience.
This should match the behavior of other software's 'Find' keyboard shortcut.
Chrome:
VSCode:
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
@jennifer-shehane I see I thought we wanted to use/focus on the filter search when pressing I assume the GUI is built on Electron, is that accurated? I'll have to find a way to get the |
@Manuel-Suarez-Abascal Let me check with the team on the implementation we want and get back to you. |
@jennifer-shehane an update on this ticket. After taking the time to think about the implementation, I decided to add an info icon & create click event to toggle the search In the beginning, I was thinking about on a Now, I need to add the functionality to the Electron menu. However, I wanted to know your opinion before moving forward in order to know if I'm on the right track. I have attached a gif below. I think the info icon is...meh, so maybe you have another icon? 🤔 EDIT: Any ideas on how to access the {
label: 'Find..',
click() {
document.querySelector('#filter').focus()
},
}, |
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 would remove the info icon. I think that we should show the placeholder text containing the keyboard shortcuts on
focus
of the searchbar. This will make them aware of it in the future and not be distracting. - We do not need to have text like 'if on Mac'. We know the operating system Cypress is running within, so you should show the appropriate command shortcut based off of the OS they are using.
- Yeah, I'm seeing now that Electron actually does not support a built in Find menu. I'm honestly not sure off the top of my head on how to get this shortcut to focus on the searchbar. It may need some kind of similar mechanism as
onLogOutClicked
uses. Feel free to reduce the scope of this PR to remove this requirement if needed.
Great idea! 💡 I have implemented it!
I have a created method called
I'm not sure how to implement this behavior, so for now, I'll reduce the scope of this ticket. |
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.
Testing this on a Mac, the display shows as Ctrl + F to make a quick search
, but that seems contradictory to what your code says it should show.
Additionally the Ctrl + F
keyboard shortcut is what functionally works on the Mac when I press it, but the keyboard shortcut we expect to use for Find on a Mac should be Cmd + F
.
We do run automated tests in Windows and Linux, but....I don't think we're running these desktop-gui tests in Windows...but I would update the desktop-gui
spec to account for which OS the test is actually running in since the behavior will be different when run on our devs Windows, Linux, or OS machines. You can check for this using Cypress.platform
. https://on.cypress.io/platform
@jennifer-shehane I have tried to find the Operating System with this code snippet:
But it states I'm stuck on how to get the Operating System. In the beginning, I tried with Can you provide me with some pointers on how to accomplish this |
User facing changelog
There is a new keyboard shortcut (CTRL + F) to search spec files in the Test Runner.
Additional details
This PR allows users to perform a search for test files with the CTRL + F command. The file where the implementation was added is
cypress\packages\desktop-gui\src\specs\specs-list.jsx
. I used a method that uses theternary operator
& addsfocus
to the searchinput
if CRTL + F is pressed. Then I called themethod
onkeydown
on thewindow
object.How has the user experience changed?
You can check the new behaviour in the gif below:
PR Tasks
issue-6269
?