Skip to content
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

Merged
merged 5 commits into from May 23, 2023

Conversation

Hephi2
Copy link
Contributor

@Hephi2 Hephi2 commented May 19, 2023

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.

@Hephi2 Hephi2 added this to the Nextcloud 27 milestone May 19, 2023
@Hephi2 Hephi2 requested a review from juliushaertl May 19, 2023 14:20
@Hephi2 Hephi2 self-assigned this May 19, 2023
@cypress
Copy link

cypress bot commented May 19, 2023

1 flaky tests on run #9922 ↗︎

0 142 1 0 Flakiness 1

Details:

fix(menubar): show selection status correctly
Project: Text Commit: b68b18c712
Status: Passed Duration: 07:14 💡
Started: May 23, 2023 11:35 AM Ended: May 23, 2023 11:42 AM
Flakiness  cypress/e2e/sync.spec.js • 1 flaky test

View Output Video

Test Artifacts
Sync > recovers from a lost connection Output Screenshots

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

@juliushaertl
Copy link
Member

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 :)

@Hephi2
Copy link
Contributor Author

Hephi2 commented May 22, 2023

I noticed that I also have to fix this bug for for when using the shortcuts.

Copy link
Collaborator

@max-nextcloud max-nextcloud left a 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.

@@ -84,17 +84,19 @@ describe('Workspace', function() {
.should('be.visible')
})

it('formats text', function() {
it('formats text', function() {
Copy link
Collaborator

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.

;[
cy.openWorkspace()

;const buttons = [
Copy link
Collaborator

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.

Comment on lines 337 to 340
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')
Copy link
Collaborator

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:

Suggested change
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.

@Hephi2
Copy link
Contributor Author

Hephi2 commented May 23, 2023

Thanks for the detailed feedback!

@Hephi2 Hephi2 force-pushed the bugfix/3907-updateIconStatus branch from 724b716 to f926ac8 Compare May 23, 2023 06:09
@Hephi2 Hephi2 marked this pull request as ready for review May 23, 2023 06:27
Copy link
Collaborator

@max-nextcloud max-nextcloud left a 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 💯 😉

@max-nextcloud
Copy link
Collaborator

Failing cypress test is known to fail from time to time.

Philipp Hempel added 4 commits May 23, 2023 11:54
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>
@Hephi2 Hephi2 force-pushed the bugfix/3907-updateIconStatus branch from f926ac8 to a897ced Compare May 23, 2023 09:54
@Hephi2
Copy link
Contributor Author

Hephi2 commented May 23, 2023

/compile

Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
@Hephi2 Hephi2 merged commit 9fef0f9 into main May 23, 2023
30 checks passed
@delete-merged-branch delete-merged-branch bot deleted the bugfix/3907-updateIconStatus branch May 23, 2023 11:45
@blizzz blizzz modified the milestones: Nextcloud 27, Nextcloud 28 May 23, 2023
@blizzz
Copy link
Member

blizzz commented May 23, 2023

if that's a bugfix that has to go to 27, it needs backporting for we are behind branch-off-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Edit icons not updated properly
5 participants