Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

chore(demos): Add toggles for custom colors and disabled state for CSS-only Select #2095

Merged
merged 3 commits into from
Jan 26, 2018

Conversation

williamernest
Copy link
Contributor

Add more demos for alternate colors and disabled state for css-only select.

@acdvorak acdvorak self-assigned this Jan 25, 2018
<div id="demo-css-only-select" class="mdc-select">
<select class="mdc-select__surface">
<option value="" selected>Pick a food group</option>
<optgroup label="First Group">
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure we want to use <optgroup> in our demos; the spec doesn't really have anything like it AFAIK.

Copy link
Contributor

@acdvorak acdvorak left a comment

Choose a reason for hiding this comment

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

One question about <optgroup>, otherwise LGTM

@acdvorak acdvorak changed the title chore(select): Update demos chore(demos): Add toggles for custom colors and disabled state for CSS-only Select Jan 25, 2018
@codecov-io
Copy link

codecov-io commented Jan 25, 2018

Codecov Report

Merging #2095 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2095   +/-   ##
=======================================
  Coverage   99.43%   99.43%           
=======================================
  Files          84       84           
  Lines        3720     3720           
  Branches      486      486           
=======================================
  Hits         3699     3699           
  Misses         21       21

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5650bf3...a9059a2. Read the comment docs.

selectCss.classList[cssAlternateColors.checked ? 'add' : 'remove']('demo-select-custom-colors');
});
cssDisabled.addEventListener('change', function() {
cssDisabled.checked ? selectCss.setAttribute('disabled', 'disabled') : selectCss.removeAttribute('disabled');
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't this be simplified to selectCss.disabled = cssDisabled.checked?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, that doesn't work. The selectCss variable is the div container that contains the select and the bottom line. A div doesn't have a disabled value, so setting it requires that we add the attribute to the div tag itself.

Our css styles apply to a disabled selector (.mdc-select[disabled]) to "Imitate native disabled functionality".

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, oops, I'm dumb and was assuming it was the select element itself, and forgot the context.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just to track the conversation here, I discussed this more offline with Will and realized that we've actually got some awkwardness with disabled CSS-only selects, in that you actually need to apply the disabled attribute to both the top-level element (to make it look disabled) and the select (to make it actually behave disabled). Needing to apply the disabled attribute to an element for which it has no native functional meaning is really weird, and likely a remnant of select's structure prior to #1097.

@williamernest williamernest changed the title chore(demos): Add toggles for custom colors and disabled state for CSS-only Select docs(select): Add toggles for custom colors and disabled state for CSS-only Select Jan 25, 2018
Copy link
Contributor

@acdvorak acdvorak left a comment

Choose a reason for hiding this comment

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

LGTM!

@acdvorak acdvorak changed the title docs(select): Add toggles for custom colors and disabled state for CSS-only Select chore(demos): Add toggles for custom colors and disabled state for CSS-only Select Jan 26, 2018
@williamernest williamernest merged commit 5cf4530 into master Jan 26, 2018
@williamernest williamernest deleted the chore/select/update-demos branch January 26, 2018 18:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants