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

Set custom cursor theme when RadioButton and CheckBox are disabled #6867

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

Conversation

LegerG
Copy link
Contributor

@LegerG LegerG commented Jul 8, 2023

What does this PR do?

When a CheckBox or a RadioButton is disabled, it's possible to set a custom cursor, applied on the container components (the cursor is also applied on the label text).

Where should the reviewer start?

src/js/components/CheckBox/StyledCheckBox.js
src/js/components/RadioButton/StyledRadioButton.js

What testing has been done on this PR?

Manual and automated tests

How should this be manually tested?

Override the default theme with <Grommet theme={{ checkBox: { disabled: { cursor: "not-allowed" } }, radioButton: { disabled: { cursor: "not-allowed" } } }}>

Do Jest tests follow these best practices?

  • [ x] screen is used for querying.
  • [ x] The correct query is used. (Refer to this list of queries)
  • [ x] userEvent is used in place of fireEvent.
  • asFragment() is used for snapshot testing.

Any background context you want to provide?

What are the relevant issues?

#6862

Screenshots (if appropriate)

image
image

Do the grommet docs need to be updated?

Yes

Should this PR be mentioned in the release notes?

Yes

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

No

@jcfilben
Copy link
Collaborator

Hey @LegerG sorry for the delay reviewing this, hoping to get a chance to take a closer look at this early next week. Thanks for your patience!

@jcfilben jcfilben added the PRty Biweekly PR reviews by grommet team with hoping of closing such PRs label Jul 20, 2023
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 thinking that we could handle setting the cursor style with a global.input.disabled.cursor prop in the theme instead of needing checkbox.disabled or radioButton.disabled. This would keep the theme structure a little simpler as well as allow for setting the stying of the disabled cursor across all input components.

@jcfilben jcfilben removed the PRty Biweekly PR reviews by grommet team with hoping of closing such PRs label Jul 20, 2023
@LegerG LegerG force-pushed the feat/custom-disabled-cursor-theme branch from d947035 to 98b9eb7 Compare July 21, 2023 06:59
@LegerG
Copy link
Contributor Author

LegerG commented Jul 21, 2023

Thank you for your response, I have updated the PR.
I will update other inputs in the next PR.

@jcfilben
Copy link
Collaborator

Hey @LegerG thanks for updating the PR! I'm thinking support should be added for global.input.disabled.cursor to all the input components within one PR. I know you mentioned tackling the rest of this work in a subsequent PR but I think ideally we don't want to have a gap of time where we have added this global theme prop but it is only working for some of the input components.

@jcfilben jcfilben added the waiting Awaiting response to latest comments label Aug 2, 2023
@LegerG
Copy link
Contributor Author

LegerG commented Aug 29, 2023

Hello, I have almost done the code but I have some points I need to discuss with you

  1. RangeSelector and DateInput don't have disabled props.
  2. Anchor and Button are not considered as inputs in the documentation but they are included in some components like SelectMultiple or FileInput. So there are some parts of the component where the cursor is different (see the screen below).
  3. MaskedInput documentation misses the disabled props, but I have implemented the feature anyway, because the props are in the code.
  4. DefaultSelectTextInput in the Select components has a comment about the disabled props. I have not implemented the feature for this one. I don't know what is the best to do.(https://github.com/grommet/grommet/blob/master/src/js/components/Select/DefaultSelectTextInput.js#L7)
  5. SelectMultiple has a bug with the showSelectedInline props and disabled. The showed selected items are not disabled. I have not fixed this feature

Different cursor inside the component
image
image

SelectMultiple issue when disabled
image
image

If you need more details about one of these points, don't hesitate. :)

@jcfilben jcfilben added PRty Biweekly PR reviews by grommet team with hoping of closing such PRs and removed waiting Awaiting response to latest comments labels Aug 31, 2023
@taysea
Copy link
Collaborator

taysea commented Sep 14, 2023

Hey there, thanks for your contribution so far and your willingness to incorporate feedback! After a bit more discussion within our team, given your comment, we've decided it would be best to support this from the theme.global.control.disabled.cursor object instead of the previous discussion around theme.global.input.

I imagine in disabledStyle, the cursor line could look something like theme.global.control.disabled.cursor || 'default'. Would you be willing to make that adjustment?

With this direction, Anchor and Button would also receive this treatment and so would any inputs that support disabled props. Regarding documentation of disabled prop on grommet docs, our approach has been not to document properties that are native HTML properties.

Thank you for your notes about RangeSelector/DateInput disabled support -- we'll file separate tickets to look into those. And I already filed one for the SelectMultiple issue you mentioned. We can take care of those issues separate from this PR.

For the DefaultSelectTextInput in the Select components I think if theme.global.control.disabled.cursor is defined we can use that for the cursor styling, otherwise we can rely on what is already there (defaultCursor={disabled === true || undefined})

@taysea taysea added waiting Awaiting response to latest comments and removed PRty Biweekly PR reviews by grommet team with hoping of closing such PRs labels Sep 14, 2023
@LegerG
Copy link
Contributor Author

LegerG commented Oct 1, 2023

I have pushed for a new version following your requirements. It is big PR, so there is a list of all components impacted in the source code (for the others, it is only tests or stories):

  • Anchor
  • Button
  • CheckBox
  • FileInput
  • RadioButton
  • RangeInput
  • Select

For now, I haven't written any tests (except for the RadioButton and CheckBox components). I plan to do it in the next commit. Do I need to write tests for all components affected by the update, or only those whose source code has been modified? (for example, only for RadioButton and not for RadioButtonGroup).

Don't hesitate if you need more details 😃

@jcfilben jcfilben removed the waiting Awaiting response to latest comments label Oct 16, 2023
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.

Just a few comments, coming along nicely!

src/js/utils/styles.js Outdated Show resolved Hide resolved
src/js/themes/base.js Outdated Show resolved Hide resolved
src/js/components/Anchor/StyledAnchor.js Outdated Show resolved Hide resolved
@jcfilben jcfilben added the waiting Awaiting response to latest comments label Oct 25, 2023
@jcfilben jcfilben added PRty Biweekly PR reviews by grommet team with hoping of closing such PRs and removed waiting Awaiting response to latest comments labels Nov 3, 2023
@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 Nov 30, 2023
@LegerG LegerG force-pushed the feat/custom-disabled-cursor-theme branch from c0adae7 to dacd001 Compare January 26, 2024 14:45
@LegerG
Copy link
Contributor Author

LegerG commented Jan 26, 2024

Hello, I have applied all your feedbacks, thanks for the review.

@jcfilben jcfilben added PRty Biweekly PR reviews by grommet team with hoping of closing such PRs and removed waiting Awaiting response to latest comments labels Jan 30, 2024
import { Grommet, Button, Box } from '../..';
import { buttonKindTheme } from './theme/buttonKindTheme';

describe('Button kind', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this file should be deleted.

@@ -552,7 +552,7 @@ describe('DataTable', () => {
}
return (
<Box>
{row.a} : {row.b}{' '}
{row.a} :{row.b}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this file should be changed by this PR, looks unrelated/potentially a local linting change

@@ -55,6 +55,8 @@ const Label = styled(Text)`
props.theme.fileInput &&
props.theme.fileInput.label &&
props.theme.fileInput.label.extend};
cursor: ${(props) =>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similar comment to above, but this should appear before the extend. Also, instead of adding default as a fallback, could we simplify the code in all instances as:

props.disabled && props.theme.global.controls.disabled.cursor ? `cursor: ${props.theme.global.controls.disabled.cursor};` : '';

Copy link
Collaborator

Choose a reason for hiding this comment

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

This should simplify the CSS to not add cursor: default in as many places.

import { Box, FileInput, Grommet } from 'grommet';

export const Disabled = () => (
<Grommet
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this has a custom theme, can you place it under a CustomThemed folder like your Anchor story?

@@ -1,27 +1,41 @@
import React from 'react';
import React, { useState } from 'react';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since the "Disabled" story already captures this behavior, can we leave this story untouched?

@@ -202,7 +202,7 @@ exports[`Grommet hpe theme 1`] = `
font-size: 18px;
line-height: 24px;
background-color: #FFFFFF;
color: #555555;
color: #6F6F6F;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like this is out of date with master.


return (
<Grommet
theme={{ global: { control: { disabled: { cursor: 'not-allowed' } } } }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment as above about putting this in a CustomThemed folder.

disabled
/>
</Box>
<Grommet
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think there are enough stories demoing this behavior, can we leave this story as it was?

{...props}
/>
</Box>
<Grommet
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think there are enough stories demoing this behavior, can we leave this story as it was?

const onChange = (event) => setValue(event.target.value);

return (
<Grommet
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think there are enough stories demoing this behavior, can we leave this story as it was?

@@ -5905,6 +5909,8 @@ exports[`Select keyboard navigation timeout 1`] = `
border-radius: 4px;
outline: none;
border: none;
opacity: 0.3;
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems suspicious that this styling is being added here even though nothing changed in select-test.

@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 Feb 1, 2024
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.

None yet

3 participants