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

[Brave News]: Fix for incorrectly styled buttons on OSX #16085

Merged
merged 1 commit into from
Nov 29, 2022

Conversation

fallaciousreasoning
Copy link
Contributor

@fallaciousreasoning fallaciousreasoning commented Nov 24, 2022

Resolves brave/brave-browser#26262

Before
image

After
image

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally: npm run test -- brave_browser_tests, npm run test -- brave_unit_tests, npm run lint, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

@fallaciousreasoning fallaciousreasoning requested a review from a team as a code owner November 24, 2022 22:04
@fallaciousreasoning fallaciousreasoning changed the title [Brave News]: Speculative fix for no paint till hover on macOS [Brave News]: Fix for incorrectly styled buttons on OSX Nov 25, 2022
@@ -207,6 +207,15 @@ void MdTextButton::SetLoading(bool loading) {
UpdateColors();
}

void MdTextButton::UpdateBackgroundColor() {
// Handled via |UpdateColorsForBrave|.
if (kind_ != kOld) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about splitting UpdateColorsForBrave() into two parts? Background part and other parts.
and moving Background parts into here to sync with upstream structure.
If upsteam changes to call UpdateBackgroundColors() from another places in the future, it could make regression?

Copy link
Contributor Author

@fallaciousreasoning fallaciousreasoning Nov 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is on my list, but it's a bit of a bigger change and I'd like to keep this as minimal as possible so we can get it uplifted. I don't think, upstream to calling UpdateBackgroundColors will break anything because it will use our colors (either the existing ones if kind_ == kOld or the new ones, otherwise).

I think it'll also require a bit more testing if we do this change here, as we could break the existing buttons, rather than just changing the brave news ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Start of a follow up PR is here: #16124

// that define their own UpdateColors() method (OmniboxChipButton) now, which
// would not work with the virtual + override approach.
// Note: We redefine UpdateBackgroundColor because we want it to be protected.
#define UpdateBackgroundColor \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and how about removing md_text_button.cc.patch while you're here?
If making UpdateColors() as virtual in protected, it could be overridden by ours also like you did for UpdateBackgroundColor()? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to make a followup PR, where do this + the background split.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, we can't remove this, because the UpdateIconForBrave method still needs the patch :/

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fallaciousreasoning I'm not following. The only patch is for BRAVE_MD_TEXT_BUTTON_UPDATE_COLORS which can be removed by making UpdateColors virtual as @simonhong is suggesting. You can call the superclass method and then do whatever BRAVE_MD_TEXT_BUTTON_UPDATE_COLORS does

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got scared off by the comment saying to not make UpdateColors virtual. However, I just tested and the OmniboxChipButtons look fine, so I guess that issue has been resolved in the 2+ years since the comment. Adding it to my follow up PR #16124

Copy link
Member

@simonhong simonhong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++ with f/u issue. This PR works great! 👍🏼

@fallaciousreasoning fallaciousreasoning merged commit 66501f4 into master Nov 29, 2022
@fallaciousreasoning fallaciousreasoning deleted the bn-subscribe-osx branch November 29, 2022 01:44
@github-actions github-actions bot added this to the 1.48.x - Nightly milestone Nov 29, 2022
@stephendonner
Copy link
Contributor

Verified PASSED using

Brave 1.48.13 Chromium: 108.0.5359.62 (Official Build) nightly (x86_64)
Revision 041930a89a990cfab0315a2d9f20d6429a4a67cf-refs/branch-heads/5359@{#938}
OS macOS Version 11.7.1 (Build 20G918)

Steps:

  1. installed 1.48.13
  2. launched Brave
  3. opened brave://flags
  4. set brave://flags/#brave-news-subscribe-button to Enabled
  5. clicked Relaunch
  6. loaded https://www.pravda.com.ua/
  7. set mode to Dark and Light, and tested button default, hover, and click/followed states

Confirmed initial/default, hover, and click/followed states are rendered correctly

Dark mode:

default hover click/followed
Screen Shot 2022-11-28 at 11 12 30 PM Screen Shot 2022-11-28 at 11 12 34 PM Screen Shot 2022-11-28 at 11 12 39 PM

Light mode:

default hover click/followed
Screen Shot 2022-11-28 at 11 13 06 PM Screen Shot 2022-11-28 at 11 13 10 PM Screen Shot 2022-11-28 at 11 13 15 PM

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

Successfully merging this pull request may close these issues.

Follow button text is invisible until hovered over
4 participants