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

Range input #6739 #7052

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

Sulaymon333
Copy link
Collaborator

What does this PR do?

fix opacity not honoured for 8-hex+alpha for range input component track color.

Where should the reviewer start?

What testing has been done on this PR?

How should this be manually tested?

Do Jest tests follow these best practices?

  • screen is used for querying.
  • The correct query is used. (Refer to this list of queries)
  • asFragment() is used for snapshot testing.

Any background context you want to provide?

What are the relevant issues?

Closes #6739

Screenshots (if appropriate)

Do the grommet docs need to be updated?

Should this PR be mentioned in the release notes?

Yes

Is this change backwards compatible or is it a breaking change?

Background compatible

@@ -64,7 +64,7 @@ const trackColorStyle = (props) => {
else {
defaultTrackColor = getRGBA(
normalizeColor(props.theme.rangeInput.track.color, props.theme),
props.theme.rangeInput.track.opacity || 1,
props.theme.rangeInput.track.opacity || undefined,
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we remove the fallback to 1 here will this be backwards compatible?

Copy link
Contributor

Choose a reason for hiding this comment

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

I belive this should be fine becuase the original implementation was shortcircuting the normalizedAlpha inside getRGBA function to pass alpha channel value as 1 always and it was simply not honouring the 8-hex value with alpha value in the first place. with the updated code being changed to undefined allows the alpha channel value to be passed appropriately and regular 6-hex value works as well. Of course, this is my understanding. we can further think through it again just to ensure the updated code is still backward compatible.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you for clarifying, I see that a fallback opacity is built into getRGBA function that falls back to 1, so it seems reasonable to just have:

getRGBA(normalizeColor(props.theme.rangeInput.track.color, props.theme), props.theme.rangeInput.track.opacity)

I don't think we need the || undefined

Copy link
Contributor

Choose a reason for hiding this comment

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

The snapshot test is now added and the redundant undefined short circut is also removed.

@taysea
Copy link
Collaborator

taysea commented Dec 12, 2023

@sulaymon-tajudeen-hpe Can you also add a snapshot test that captures the 8-digit HEX use case ?

@jcfilben jcfilben added the waiting Awaiting response to latest comments label Dec 14, 2023
Copy link
Collaborator

@taysea taysea left a comment

Choose a reason for hiding this comment

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

Thank you for the fix!

@taysea taysea requested a review from jcfilben January 3, 2024 21:50
@jcfilben jcfilben removed the waiting Awaiting response to latest comments label Jan 3, 2024
Copy link
Collaborator

@jcfilben jcfilben left a comment

Choose a reason for hiding this comment

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

There are some places in the StyledRangeInput.js file where we still have props.theme.rangeInput.track.opacity || 1 or opacity || 1 (see lines 82 and 120). Just wanted to understand why we are keeping it on those lines

@sulaymon-tajudeen-hpe
Copy link
Contributor

Both lines 82 and 120 did not seems to make any difference with || 1 on the 8-digit hex code, that is why I did not remove them initially. For the purpose of cnsistency and since || 1 is already taken care of from the original getRGBA function that falls back to 1, the || 1 is now removed from both lines 82 and 120.

@jcfilben jcfilben added the PRty Biweekly PR reviews by grommet team with hoping of closing such PRs label Jan 4, 2024
Copy link
Collaborator

@jcfilben jcfilben left a comment

Choose a reason for hiding this comment

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

I'm not seeing the opacity coming through on cases where we specify an 8 digit hex within the RangeInput theme. For example if we specify something like this in the theme only the thumb color is respecting the opacity

rangeInput: {
  thumb: {
    color: '#7f03fc20',
  },
  track: {
    lower: {
      color: '#fc03a925',
    },
    upper: {
      color: '#705a6923',
    },
  },
}

@jcfilben jcfilben added waiting Awaiting response to latest comments and removed PRty Biweekly PR reviews by grommet team with hoping of closing such PRs labels Jan 9, 2024
@taysea taysea self-requested a review January 18, 2024 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting Awaiting response to latest comments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RangeInput not respecting background color opacity
4 participants