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(menubar): show selection status correctly #4211
Conversation
1 flaky tests on run #9922 ↗︎
Details:
cypress/e2e/sync.spec.js • 1 flaky test
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. |
Nice, change looks good. I think this is also a good case to cover with a simple cypress test that asserts that the button has the active state class. @max-nextcloud Maybe you can look into that together with @Hephi2 next week and guide him a bit on the first steps with cypress :) |
I noticed that I also have to fix this bug for for when using the shortcuts. |
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.
All in all looks great. Thanks a lot for looking into this. I added a few comments to the eslint complaints. Hope that makes it easier to understand and fix them.
When in doubt please ask in the talk channel.
cypress/e2e/workspace.spec.js
Outdated
@@ -84,17 +84,19 @@ describe('Workspace', function() { | |||
.should('be.visible') | |||
}) | |||
|
|||
it('formats text', function() { | |||
it('formats text', function() { |
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.
There are a few formatting issues reported by eslint like this one.
No trailing whitespace should follow the {
.
In order to see these more easily it might be useful to install an eslint extension in you vscode. That should highlight such issues automatically.
cypress/e2e/workspace.spec.js
Outdated
;[ | ||
cy.openWorkspace() | ||
|
||
;const buttons = [ |
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 extra ;
at the beginning of the line was here because the line started with an array:
cy.getContent().type('{selectall}')
;[
Without a ;
Javascript would interpret the [
as an index into an array (as in cy.getContent().type('{selectall}')[1]
)
Now that you are using a variable (much better) there's no more need for the semicolon.
cypress/e2e/workspace.spec.js
Outdated
cy.getContent().type('Format me{selectall}') | ||
.find(`${tag}`) | ||
.should('contain', 'Format me').type('{del}') | ||
cy.getMenuEntry(button).click().should('have.class', 'is-active').click().should('not.have.class', 'is-active') |
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.
Cypress eslint extension is complaining about these lines because you are chaining off commands.
What does it mean by that:
cy.getContent().type('Format me{selectall}').find(...)
.type()
is a command. (So is .click()
).
The problem is rooted in how cypress works. For queries like find()
it will look for the element. If it does not exist yet it will retry until the element exists or it times out.
If the find()
command is chained from the type()
command there's no safe way for cypress to retry without calling the type()
command multiple times.
So whenever you have a command that actually changes something you need to end the chain:
cy.getContent().type('Format me{selectall}') | |
.find(`${tag}`) | |
.should('contain', 'Format me').type('{del}') | |
cy.getMenuEntry(button).click().should('have.class', 'is-active').click().should('not.have.class', 'is-active') | |
cy.getContent().type('Format me{selectall}') | |
cy.getContent().find(`${tag}`) | |
.should('contain', 'Format me').type('{del}') | |
cy.getMenuEntry(button).click() | |
cy.getMenuEntry(button).should('have.class', 'is-active').click() | |
cy.getMenuEntry(button).should('not.have.class', 'is-active') |
This is only checked since a short time - so you will still find old documentation and even code that does not follow this rule.
Thanks for the detailed feedback! |
724b716
to
f926ac8
Compare
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.
Looks really good. Thanks for diving into this!
🧪 Bonus points for tests included 💯 😉
Failing cypress test is known to fail from time to time. |
Buttons in the menubar like bold, italic, underline and strikethrough are show now if they are selected or not right after the selection. Signed-off-by: Philipp Hempel <philipp.hempel@nextcloud.com>
Test if selection status of buttons is also correct when not using with a selected text --signoff Signed-off-by: Philipp Hempel <philipp.hempel@nextcloud.com>
Now the status of the buttons is updated after using the shortcuts for them as well --signoff Signed-off-by: Philipp Hempel <philipp.hempel@nextcloud.com>
--signoff Signed-off-by: Philipp Hempel <philipp.hempel@nextcloud.com>
f926ac8
to
a897ced
Compare
/compile |
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
if that's a bugfix that has to go to 27, it needs backporting for we are behind branch-off- |
Buttons in the menubar like bold, italic, underline and strikethrough are show now if they are selected or not right after the selection.
📝 Summary
Before the fix the is-active status of the icon buttons for bold, italic, underline and strikethrough did not change after selecting. Now the status is updated after the click to show if the modifiers are active even before starting to write with those.