Skip to content

Conversation

@jasmussen
Copy link
Contributor

Fixes #12049.

This PR fixes an issue where a togglecontrol, wrapped in a Disabled component, would show a double border. The issue was that it inherited a border from the parent checkbox style (because the toggle is technically a reskinned checkbox).

Before:

screenshot 2018-11-20 at 10 04 48

After:

screenshot 2018-11-20 at 10 04 34

Fixes #12049.

This PR fixes an issue where a togglecontrol, wrapped in a Disabled component, would show a double border. The issue was that it inherited a border from the parent checkbox style (because the toggle is technically a reskinned checkbox).
@jasmussen jasmussen added the [Type] Bug An existing feature does not function as intended label Nov 20, 2018
@jasmussen jasmussen added this to the 4.6 milestone Nov 20, 2018
@jasmussen jasmussen self-assigned this Nov 20, 2018
@jasmussen jasmussen requested a review from a team November 20, 2018 09:08
Copy link
Member

@sirreal sirreal left a comment

Choose a reason for hiding this comment

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

I didn't recompile styles, but I verified that a toggle control wrapped in Disabled does not have the double border when manually adding this style via browser dev tools:

.components-toggle-control .components-base-control__field .components-form-toggle__input {
    border: none;
}

Looks like this fixes the issue. Thanks!

@jasmussen
Copy link
Contributor Author

Thanks for the review! Not sure why the button doesn't turn green with your approval. But in any case, it's milestoned, so we'll get it in.

Copy link
Member

@simison simison left a comment

Choose a reason for hiding this comment

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

Compiled and confirmed this fixes it for both content area and the sidebar:

image

@simison
Copy link
Member

simison commented Nov 20, 2018

Not sure why the button doesn't turn green with your approval.

We don't have special rights to this repo. 😉 ✨

@simison
Copy link
Member

simison commented Nov 20, 2018

Looks like checked state is still messed up even with this branch:

image

via Automattic/wp-calypso#28701

@jasmussen
Copy link
Contributor Author

CC: @ockham, perhaps the real fix is to add a disabled style to the component itself?

@ockham
Copy link
Contributor

ockham commented Nov 20, 2018

CC: @ockham, perhaps the real fix is to add a disabled style to the component itself?

Not sure I understand -- adding disabled styling was what I planned to do in the first place: #12105

}

// This overrides a border style that is inherited from parent checkbox styles.
.components-form-toggle__input {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this styles components-form-toggle__input -- should the styling actually go to packages/components/src/form-toggle/style.scss so it'd also apply to FormToggle when not wrapped in a ToggleControl? Cf Automattic/wp-calypso#28701

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me take a look as I address the other item from @simison, thanks!

@jasmussen
Copy link
Contributor Author

Not sure I understand -- adding disabled styling was what I planned to do in the first place: #12105

Sorry I guess I just left this there without too much context :D

What i meant was that instead of wrapping the FormToggle in a Disabled component to disable it, perhaps having an actual disabled prop on the form toggle would be a better approach? Though I suppose both use cases need to work.

- Add a better disabled state that works for both checked and unchecked states.
- Move code to the right component.
- Fix some additional bleed issues.
@jasmussen
Copy link
Contributor Author

Thanks for the review, everyone. Fixed a few issues, including those mentioned:

screenshot 2018-11-20 at 15 26 58

screenshot 2018-11-20 at 15 28 07

Copy link
Contributor

@ockham ockham left a comment

Choose a reason for hiding this comment

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

Thanks @jasmussen, looks great! Any chance this makes it into 4.5? Would be great for people testing the Jetpack beta after today's code freeze so they won't run into Automattic/wp-calypso#28701 😄

@jasmussen
Copy link
Contributor Author

Thanks for the review. I think that's up to @youknowriad.

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

How can I go against three approvals?

@youknowriad youknowriad modified the milestones: 4.6, 4.5 Nov 20, 2018
@youknowriad youknowriad merged commit 3f74cd1 into master Nov 20, 2018
@youknowriad youknowriad deleted the try/disabled-toggle-fix branch November 20, 2018 17:02
@ockham
Copy link
Contributor

ockham commented Nov 20, 2018

Thanks @jasmussen and @youknowriad! ❤️

daniloercoli added a commit that referenced this pull request Nov 20, 2018
…rnmobile/wire-on-replace-para-block

* 'master' of https://github.com/WordPress/gutenberg:
  Remove "permalink settings" link from permalink panel. (#12121)
  preserve quote content (#12122)
  Replace gutenberg domain with default for Core blocks (#12108)
  Fix issue with disabled togglecontrol double border (#12091)
  Fix the TinyMCE init array (#10968)
ockham added a commit to Automattic/wp-calypso that referenced this pull request Nov 20, 2018
Use the `Disabled` component rather than a `disabled` prop to conditionally wrap `FormToggle` when the `toggleable` attribute is `false`. This should style the toggles properly when using Gutenberg `master` or a version that includes WordPress/gutenberg#12091.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ToggleControl visually broken when wrapped in Disabled component

6 participants