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 missing active state for outline buttons #39099

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

theodorejb
Copy link

@theodorejb theodorejb commented Aug 23, 2023

Description

Previously there was no visual feedback when clicking an outline button, which made them feel somewhat buggy/broken. This pull request adds an active state to outline buttons so they respond similarly to other buttons when selected.

It also updates the hover state for outline buttons to match that of regular buttons. Previously if an outline button was next to a regular button, when hovered it looked the same as the non-hovered regular button which could cause confusion.

Type of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have read the contributing guidelines
  • My code follows the code style of the project (using npm run lint)
  • My change introduces changes to the documentation
  • I have added tests to cover my changes
  • All existing tests passed

Live previews

Related issues

Resolves #39085

@xeron
Copy link

xeron commented Aug 23, 2023

Please test with the following:

<button type="button" class="btn btn-outline-light active" data-bs-toggle="button" aria-pressed="true">Light</button>

I tried your fix and it doesn't look correct – active button state is shaded which doesn't match normal button where hover is shaded. I think hover supposed to be shaded like in usual button, not active-background?

@xeron
Copy link

xeron commented Aug 23, 2023

NVM I just realized normal button active state is shaded too 🤦

@xeron
Copy link

xeron commented Aug 23, 2023

Another issue to think about is mobile devices behavior – this fix makes inactive hovered button brighter then active which helps a bit, but it's still confusing to the end user as they're not sure if state actually changed or not because button doesn't look like inactive one (because it's stays hovered until user taps something else).

@theodorejb
Copy link
Author

theodorejb commented Aug 23, 2023

@xeron I'm not sure what you you're referring to as confusing; I tested on mobile and it seems to work as expected. This patch doesn't affect hover state - it only adds the missing active state (matching the active state of regular buttons).

Edit: it's true that the hover state doesn't have the shade that it does on regular buttons, but my understanding is that this has always been the case and is the intended design for outline buttons. I think a change to the hover color would require a separate discussion and merge request.

@xeron
Copy link

xeron commented Aug 23, 2023

What's confusing on mobile is after clicking the button it stays highlighted because of the sticky hover effect:

https://codepen.io/iXeron/pen/xxmGazY

Screenshot 2023-08-23 at 4 42 23 PM

https://css-tricks.com/solving-sticky-hover-states-with-media-hover-hover/

I posted possible solution in my bug report comments:

@media (hover: none) {
  .btn-outline-light:hover {
    color: $gray-100;
    background-color: transparent;
  }
  .btn-outline-light.active:hover {
    color: #000;
    background-color: $gray-100;
  }
}

I agree it probably needs a separate design discussion but it also was part of my bug report as toggle buttons are barely usable on mobile because of that.

@theodorejb
Copy link
Author

What's confusing on mobile is after clicking the button it stays highlighted because of the sticky hover effect

I see. Note that regular buttons have this sticky-hover behavior on mobile too, so it's not something specific to outline buttons (nor is it affected by this pull request).

My goal with this patch is to specifically address the missing active state on outline buttons, and not change anything else. As you said the sticky-hover effect may warrant a separate design discussion.

@theodorejb
Copy link
Author

@mdo Is there any chance this fix could be included in 5.3.2?

CC @julien-deramond

@julien-deramond
Copy link
Member

julien-deramond commented Sep 13, 2023

@theodorejb The content of the v5.3.2 is now fixed in order to release the patch regarding Dart Sass really soon. The next version will prolly be v5.3.3. I'll integrate the review of this PR for this v5.3.3.

We haven't checked yet if the issue is something we'd like to provide in Bootstrap, so we'll try to check the suggestion in the issue and your corresponding PR.

@theodorejb
Copy link
Author

I added a second commit which updates the outline button hover color to match that of regular buttons. Previously the hover state was the same as the non-hover state of regular buttons, which could cause confusion when hovering an outline button placed next to a non-outline button. This also improves the active state appearance since it no longer looks too dark in comparison to the hover color.

Previously the hover state was the same as the non-hover state for regular buttons, which could cause confusion when a hovered outline button is near a regular button.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Outline buttons have the same active and hover color
3 participants