-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix(list): added #adapter.listItemAtIndexHasClass to prevent user state change to disabled items #4922
fix(list): added #adapter.listItemAtIndexHasClass to prevent user state change to disabled items #4922
Changes from 6 commits
fb480ef
cd8cf01
0d6bb26
6064a98
4145c88
5c04ea3
f059f8d
bd13af1
fd9a861
7270720
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,19 +40,21 @@ const strings = { | |
ARIA_ORIENTATION_HORIZONTAL: 'horizontal', | ||
ARIA_ROLE_CHECKBOX_SELECTOR: '[role="checkbox"]', | ||
ARIA_SELECTED: 'aria-selected', | ||
CHECKBOX_RADIO_SELECTOR: 'input[type="checkbox"]:not(:disabled), input[type="radio"]:not(:disabled)', | ||
CHECKBOX_SELECTOR: 'input[type="checkbox"]:not(:disabled)', | ||
CHECKBOX_RADIO_SELECTOR: 'input[type="checkbox"], input[type="radio"]', | ||
CHECKBOX_SELECTOR: 'input[type="checkbox"]', | ||
CHILD_ELEMENTS_TO_TOGGLE_TABINDEX: ` | ||
.${cssClasses.LIST_ITEM_CLASS} button:not(:disabled), | ||
.${cssClasses.LIST_ITEM_CLASS} a | ||
`, | ||
ENABLED_CHECKBOX_RADIO_SELECTOR: 'input[type="checkbox"]:not(:disabled), input[type="radio"]:not(:disabled)', | ||
ENABLED_CHECKBOX_SELECTOR: 'input[type="checkbox"]:not(:disabled)', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two ENABLED_* constants are not used anywhere at this point. They are essentially renamed versions of the old There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can remove if unused. |
||
FOCUSABLE_CHILD_ELEMENTS: ` | ||
.${cssClasses.LIST_ITEM_CLASS} button:not(:disabled), | ||
.${cssClasses.LIST_ITEM_CLASS} a, | ||
.${cssClasses.LIST_ITEM_CLASS} input[type="radio"]:not(:disabled), | ||
.${cssClasses.LIST_ITEM_CLASS} input[type="checkbox"]:not(:disabled) | ||
`, | ||
RADIO_SELECTOR: 'input[type="radio"]:not(:disabled)', | ||
RADIO_SELECTOR: 'input[type="radio"]', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This began as an effort for better naming consistency but actually fixes a bug where if the first radio element of a list is disabled, the remaining radio list breaks. This was due to the following lines in
|
||
}; | ||
|
||
const numbers = { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
<!DOCTYPE html> | ||
<!-- | ||
Copyright 2018 Google Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
--> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Disabled Checkbox List - MDC Web Screenshot Test</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="stylesheet" href="../../../out/mdc.list.css"> | ||
<link rel="stylesheet" href="../../../out/mdc.checkbox.css"> | ||
<link rel="stylesheet" href="../../../out/spec/fixture.css"> | ||
<link rel="stylesheet" href="../../../out/spec/mdc-list/fixture.css"> | ||
|
||
<!-- Global site tag (gtag.js) - Google Analytics --> | ||
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-118996389-2"></script> | ||
<script> | ||
window.dataLayer = window.dataLayer || []; | ||
function gtag(){dataLayer.push(arguments);} | ||
gtag('js', new Date()); | ||
gtag('config', 'UA-118996389-2'); | ||
</script> | ||
</head> | ||
|
||
<body class="test-container"> | ||
<main class="test-viewport test-viewport--mobile"> | ||
<div class="test-layout"> | ||
<div class="test-cell test-cell--list"> | ||
<ul class="mdc-list test-checkbox-list" style="list-style-type: none;" role="group" aria-label="Checkbox options"> | ||
<li class="mdc-list-item" role="checkbox" aria-checked="false"> | ||
<span class="mdc-list-item__graphic"> | ||
<div class="mdc-checkbox"> | ||
<input type="checkbox" | ||
class="mdc-checkbox__native-control" | ||
id="test-list-checkbox-item-1" /> | ||
<div class="mdc-checkbox__background"> | ||
<svg class="mdc-checkbox__checkmark" | ||
viewBox="0 0 24 24"> | ||
<path class="mdc-checkbox__checkmark-path" | ||
fill="none" | ||
d="M1.73,12.91 8.1,19.28 22.79,4.59"/> | ||
</svg> | ||
<div class="mdc-checkbox__mixedmark"></div> | ||
</div> | ||
</div> | ||
</span> | ||
<label class="mdc-list-item__text test-list-item__label" for="test-list-checkbox-item-1">Option 1</label> | ||
</li> | ||
<li class="mdc-list-item mdc-list-item--disabled" role="checkbox" aria-checked="true" tabindex="0"> | ||
<span class="mdc-list-item__graphic"> | ||
<div class="mdc-checkbox mdc-checkbox--disabled"> | ||
<input type="checkbox" | ||
class="mdc-checkbox__native-control" | ||
id="test-list-checkbox-item-2" | ||
checked | ||
disabled /> | ||
<div class="mdc-checkbox__background"> | ||
<svg class="mdc-checkbox__checkmark" | ||
viewBox="0 0 24 24"> | ||
<path class="mdc-checkbox__checkmark-path" | ||
fill="none" | ||
d="M1.73,12.91 8.1,19.28 22.79,4.59"/> | ||
</svg> | ||
<div class="mdc-checkbox__mixedmark"></div> | ||
</div> | ||
</div> | ||
</span> | ||
<label class="mdc-list-item__text test-list-item__label" for="test-list-checkbox-item-2">Option 2</label> | ||
</li> | ||
<li class="mdc-list-item" role="checkbox" aria-checked="false"> | ||
<span class="mdc-list-item__graphic"> | ||
<div class="mdc-checkbox"> | ||
<input type="checkbox" | ||
class="mdc-checkbox__native-control" | ||
id="test-list-checkbox-item-3" /> | ||
<div class="mdc-checkbox__background"> | ||
<svg class="mdc-checkbox__checkmark" | ||
viewBox="0 0 24 24"> | ||
<path class="mdc-checkbox__checkmark-path" | ||
fill="none" | ||
d="M1.73,12.91 8.1,19.28 22.79,4.59"/> | ||
</svg> | ||
<div class="mdc-checkbox__mixedmark"></div> | ||
</div> | ||
</div> | ||
</span> | ||
<label class="mdc-list-item__text test-list-item__label" for="test-list-checkbox-item-3">Option 3</label> | ||
</li> | ||
<li class="mdc-list-item" role="checkbox" aria-checked="false"> | ||
<span class="mdc-list-item__graphic"> | ||
<div class="mdc-checkbox"> | ||
<input type="checkbox" | ||
class="mdc-checkbox__native-control" | ||
id="test-list-checkbox-item-4" /> | ||
<div class="mdc-checkbox__background"> | ||
<svg class="mdc-checkbox__checkmark" | ||
viewBox="0 0 24 24"> | ||
<path class="mdc-checkbox__checkmark-path" | ||
fill="none" | ||
d="M1.73,12.91 8.1,19.28 22.79,4.59"/> | ||
</svg> | ||
<div class="mdc-checkbox__mixedmark"></div> | ||
</div> | ||
</div> | ||
</span> | ||
<label class="mdc-list-item__text test-list-item__label" for="test-list-checkbox-item-4">Option 4</label> | ||
</li> | ||
<li class="mdc-list-item" role="checkbox" aria-checked="false"> | ||
<span class="mdc-list-item__graphic"> | ||
<div class="mdc-checkbox"> | ||
<input type="checkbox" | ||
class="mdc-checkbox__native-control" | ||
id="test-list-checkbox-item-5" /> | ||
<div class="mdc-checkbox__background"> | ||
<svg class="mdc-checkbox__checkmark" | ||
viewBox="0 0 24 24"> | ||
<path class="mdc-checkbox__checkmark-path" | ||
fill="none" | ||
d="M1.73,12.91 8.1,19.28 22.79,4.59"/> | ||
</svg> | ||
<div class="mdc-checkbox__mixedmark"></div> | ||
</div> | ||
</div> | ||
</span> | ||
<label class="mdc-list-item__text test-list-item__label" for="test-list-checkbox-item-5">Option 5</label> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</main> | ||
|
||
<!-- Automatically provides/replaces `Promise` if missing or broken --> | ||
<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.auto.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/fontfaceobserver/2.0.13/fontfaceobserver.standalone.js"></script> | ||
<script src="../../../out/material-components-web.js"></script> | ||
<script src="../../../out/spec/fixture.js"></script> | ||
<script src="../../../out/spec/mdc-list/fixture.js"></script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
<!DOCTYPE html> | ||
<!-- | ||
Copyright 2018 Google Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
--> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Disabled Radio List - MDC Web Screenshot Test</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="stylesheet" href="../../../out/mdc.list.css"> | ||
<link rel="stylesheet" href="../../../out/mdc.radio.css"> | ||
<link rel="stylesheet" href="../../../out/spec/fixture.css"> | ||
<link rel="stylesheet" href="../../../out/spec/mdc-list/fixture.css"> | ||
|
||
<!-- Global site tag (gtag.js) - Google Analytics --> | ||
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-118996389-2"></script> | ||
<script> | ||
window.dataLayer = window.dataLayer || []; | ||
function gtag(){dataLayer.push(arguments);} | ||
gtag('js', new Date()); | ||
gtag('config', 'UA-118996389-2'); | ||
</script> | ||
</head> | ||
|
||
<body class="test-container"> | ||
<main class="test-viewport test-viewport--mobile"> | ||
<div class="test-layout"> | ||
<div class="test-cell test-cell--list"> | ||
<ul class="mdc-list test-radio-list" role="radiogroup" style="list-style-type: none;"> | ||
<li class="mdc-list-item" role="radio" aria-checked="false"> | ||
<span class="mdc-list-item__graphic"> | ||
<div class="mdc-radio"> | ||
<input class="mdc-radio__native-control" | ||
type="radio" | ||
id="test-list-radio-item-1" | ||
name="test-list-radio-item-group" | ||
value="1"> | ||
<div class="mdc-radio__background"> | ||
<div class="mdc-radio__outer-circle"></div> | ||
<div class="mdc-radio__inner-circle"></div> | ||
</div> | ||
</div> | ||
</span> | ||
<label class="mdc-list-item__text test-list-item__label" for="test-list-radio-item-1">Option 1</label> | ||
</li> | ||
<li class="mdc-list-item mdc-list-item--disabled" role="radio" aria-checked="true" tabindex="0"> | ||
<span class="mdc-list-item__graphic"> | ||
<div class="mdc-radio mdc-radio--disabled"> | ||
<input class="mdc-radio__native-control" | ||
type="radio" | ||
id="test-list-radio-item-2" | ||
name="test-list-radio-item-group" | ||
value="2" | ||
checked | ||
disabled > | ||
<div class="mdc-radio__background"> | ||
<div class="mdc-radio__outer-circle"></div> | ||
<div class="mdc-radio__inner-circle"></div> | ||
</div> | ||
</div> | ||
</span> | ||
<label class="mdc-list-item__text test-list-item__label" for="test-list-radio-item-2">Option 2</label> | ||
</li> | ||
<li class="mdc-list-item" role="radio" aria-checked="false"> | ||
<span class="mdc-list-item__graphic"> | ||
<div class="mdc-radio"> | ||
<input class="mdc-radio__native-control" | ||
type="radio" | ||
id="test-list-radio-item-3" | ||
name="test-list-radio-item-group" | ||
value="3"> | ||
<div class="mdc-radio__background"> | ||
<div class="mdc-radio__outer-circle"></div> | ||
<div class="mdc-radio__inner-circle"></div> | ||
</div> | ||
</div> | ||
</span> | ||
<label class="mdc-list-item__text test-list-item__label" for="test-list-radio-item-3">Option 3</label> | ||
</li> | ||
<li class="mdc-list-item" role="radio" aria-checked="false"> | ||
<span class="mdc-list-item__graphic"> | ||
<div class="mdc-radio"> | ||
<input class="mdc-radio__native-control" | ||
type="radio" | ||
id="test-list-radio-item-4" | ||
name="test-list-radio-item-group" | ||
value="4"> | ||
<div class="mdc-radio__background"> | ||
<div class="mdc-radio__outer-circle"></div> | ||
<div class="mdc-radio__inner-circle"></div> | ||
</div> | ||
</div> | ||
</span> | ||
<label class="mdc-list-item__text test-list-item__label" for="test-list-radio-item-4">Option 4</label> | ||
</li> | ||
<li class="mdc-list-item" role="radio" aria-checked="false"> | ||
<span class="mdc-list-item__graphic"> | ||
<div class="mdc-radio"> | ||
<input class="mdc-radio__native-control" | ||
type="radio" | ||
id="test-list-radio-item-5" | ||
name="test-list-radio-item-group" | ||
value="5"> | ||
<div class="mdc-radio__background"> | ||
<div class="mdc-radio__outer-circle"></div> | ||
<div class="mdc-radio__inner-circle"></div> | ||
</div> | ||
</div> | ||
</span> | ||
<label class="mdc-list-item__text test-list-item__label" for="test-list-radio-item-5">Option 5</label> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</main> | ||
|
||
<!-- Automatically provides/replaces `Promise` if missing or broken. --> | ||
<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.auto.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/fontfaceobserver/2.0.13/fontfaceobserver.standalone.js"></script> | ||
<script src="../../../out/material-components-web.js"></script> | ||
<script src="../../../out/spec/fixture.js"></script> | ||
<script src="../../../out/spec/mdc-list/fixture.js"></script> | ||
</body> | ||
</html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also need to sync this to internal and implement this adapter before merging it.