question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The button hoverIndicator property does not work as expected

See original GitHub issue

This is a separate issue, but related to #5680

Expected Behavior

Given that #5680 is fixed or just using JavaScript instead of TypeScript, the button defined as follows:

<Button 
  primary
  label='Click Me!'
  onClick={doStuff}
  hoverIndicator {{ background: { color: 'red' }, elevation: 'small' }} />

Should have a noticeable shadow when hovered over with the mouse.

Actual Behavior

There is no noticeable shadow. Looking at the actual styles in the browser dev tools I see that the shadow that should have been applied by the elevation: 'small' property is being overwritten by what is apparently the “default” shadow of the Button hover state:

.iHgHqy:hover {
  background-color: red;
  color: #000000;
  box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.20); // <- this is the desired shadow set by the "elevation" property
  box-shadow: 0px 0px 0px 2px #439F00; // <- this is the "default" shadow apparently derived from the base button color
}
  • Grommet version: 2.18.0
  • Browser Name and version: MS Edge
  • Operating System and version (desktop or mobile): macOS Big Sur

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
chrisvalmontecommented, Nov 3, 2021

I fixed this initially in #5729, but the PR handled too many concerns so I had to remove it… the box-shadow returned from getHoverIndicatorStyle (at src/js/utils/background.js) gets overriden by the box-shadow defined in StyledButton (at src/js/components/Button/StyledButton.js, line 105) when the plain prop is falsey

1reaction
tromgycommented, Oct 25, 2021

Here’s the sandbox link that shows the issue. Open it and then click “Button” under “Controls” on the page shown in preview.

You should see the behavior described. You can also right-click the button, select Inspect, and then force the “hover” state using the browser dev tools and see the styles:

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

v2 Improve Button docs for hoverIndicator · Issue #3330 - GitHub
The Button 's hoverIndicator prop does not work as the docs say. Expected Behavior. Something like: { dark: { color: 'dark-2', opacity: '1',...
Read more >
css - :hover does not seem to be working on custom buttons
I have a couple custom buttons that are working and look fine, except the hover stopped working (should change color on hover.
Read more >
Hover and normal state background - General - Forum | Webflow
Hi, For the donation button, I select the Hover state and set the background color opacity to 100%. Then I go to the...
Read more >
Styling links - Learn web development | MDN
For example, states like hover can be used to style many different elements, not just links — you might want to style the...
Read more >
Understanding SC 1.4.13:Content on Hover or Focus (Level AA)
Where receiving and then removing pointer hover or keyboard focus triggers additional content to become visible and then hidden, the following are true:....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found