-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(dropdown): trigger button should never be disabled (#2671)
* fix(dropdown): trigger button should never be disabled * fix(dropdown): made disabled content accessible by keyboard users * test(dropdown): updated tests for disabled dropdown * fix(dropdown): allow disabled menu to be visible * fix(dropdown): removed focus, active, and focer styles from disabled * fix(dropdown): disabled state available to SR * fix(dropdown): updated disabled css * fix(dropdown): updated disabled css * fix(dropdown): adds disabled context * fix(dropdown): updated disabled css * fix(dropdown): update elements/pf-dropdown/pf-dropdown.ts Co-authored-by: Benny Powers - עם ישראל חי! <[email protected]> * fix(dropdown): minimize public APIs * chore: fix commitlint comment script * docs(dropdown): changeset * style: whitespace and formatting * fix(dropdown): prevent clicks on disabled menu items from falling through * chore: fix wireit script order * fix(dropdown): remove aria from dropdown-item host * fix(button): show slotted icon * fix(dropdown)!: change `trigger` slot to `toggle`, etc - move disabled context to pf-dropdown element - use pfv4 css tokens - correct toggle styling for variants, in particular the layout * fix(dropdown): prevent default on disabled item * fix(dropdown): decruft menu's aria-disabled state is set on internals * style(button): import order * fix(dropdown): cursor for disabled link items --------- Co-authored-by: Benny Powers <[email protected]> Co-authored-by: Benny Powers - עם ישראל חי! <[email protected]>
- Loading branch information
1 parent
91c8c77
commit 8e52f62
Showing
24 changed files
with
583 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@patternfly/elements": patch | ||
--- | ||
`<pf-dropdown>`: ensure that dropdown menu contents are accessible to keyboard | ||
and screen-reader users even when the dropdown or its toggle is disabled. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
"@patternfly/elements": patch | ||
--- | ||
`<pf-button>`: show slotted icon when it is present |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { createContextWithRoot } from '@patternfly/pfe-core/functions/context.js'; | ||
|
||
export interface PfDropdownContext { | ||
disabled: boolean; | ||
} | ||
|
||
export const context = | ||
createContextWithRoot<PfDropdownContext >(Symbol('pf-dropdown-menu-context')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<p> | ||
<small> | ||
<em>Note:</em> When using a custom toggle, you must slot in a <code>pf-dropdown-menu</code>. | ||
</small> | ||
<span id="switch-group"> | ||
<pf-switch id="disable-all"></pf-switch> | ||
<label for="disable-all"><span data-state="on">Enable</span><span data-state="off">Disable</span> all dropdowns</label> | ||
</span> | ||
</p> | ||
|
||
<pf-dropdown id="control"> | ||
<pf-button variant="control" slot="toggle"> | ||
Control toggle | ||
<pf-icon size="md" icon="caret-down"></pf-icon> | ||
</pf-button> | ||
<pf-dropdown-menu slot="menu"> | ||
<pf-dropdown-item>item4</pf-dropdown-item> | ||
<hr> | ||
<pf-dropdown-group label="Group 1"> | ||
<pf-dropdown-item>item1</pf-dropdown-item> | ||
<pf-dropdown-item>item2</pf-dropdown-item> | ||
<hr> | ||
<pf-dropdown-item>item3</pf-dropdown-item> | ||
</pf-dropdown-group> | ||
<pf-dropdown-group label="Group 2"> | ||
<pf-dropdown-item>item1</pf-dropdown-item> | ||
<pf-dropdown-item>item2</pf-dropdown-item> | ||
<pf-dropdown-item>item3</pf-dropdown-item> | ||
<pf-dropdown-item disabled>disabled</pf-dropdown-item> | ||
</pf-dropdown-group> | ||
</pf-dropdown-menu> | ||
</pf-dropdown> | ||
|
||
<pf-dropdown id="primary"> | ||
<pf-button variant="primary" slot="toggle">Primary toggle</pf-button> | ||
<pf-dropdown-menu slot="menu"> | ||
<pf-dropdown-item>item4</pf-dropdown-item> | ||
<hr> | ||
<pf-dropdown-group label="Group 1"> | ||
<pf-dropdown-item>item1</pf-dropdown-item> | ||
<pf-dropdown-item>item2</pf-dropdown-item> | ||
<hr> | ||
<pf-dropdown-item>item3</pf-dropdown-item> | ||
</pf-dropdown-group> | ||
<pf-dropdown-group label="Group 2"> | ||
<pf-dropdown-item>item1</pf-dropdown-item> | ||
<pf-dropdown-item>item2</pf-dropdown-item> | ||
<pf-dropdown-item>item3</pf-dropdown-item> | ||
<pf-dropdown-item disabled>disabled</pf-dropdown-item> | ||
</pf-dropdown-group> | ||
</pf-dropdown-menu> | ||
</pf-dropdown> | ||
|
||
<pf-dropdown id="secondary"> | ||
<pf-button variant="secondary" slot="toggle">Secondary toggle</pf-button> | ||
<pf-dropdown-menu slot="menu"> | ||
<pf-dropdown-item>item4</pf-dropdown-item> | ||
<hr> | ||
<pf-dropdown-group label="Group 1"> | ||
<pf-dropdown-item>item1</pf-dropdown-item> | ||
<pf-dropdown-item>item2</pf-dropdown-item> | ||
<hr> | ||
<pf-dropdown-item>item3</pf-dropdown-item> | ||
</pf-dropdown-group> | ||
<pf-dropdown-group label="Group 2"> | ||
<pf-dropdown-item>item1</pf-dropdown-item> | ||
<pf-dropdown-item>item2</pf-dropdown-item> | ||
<pf-dropdown-item>item3</pf-dropdown-item> | ||
<pf-dropdown-item disabled>disabled</pf-dropdown-item> | ||
</pf-dropdown-group> | ||
</pf-dropdown-menu> | ||
</pf-dropdown> | ||
|
||
<pf-dropdown id="plain"> | ||
<pf-button plain slot="toggle">Plain toggle</pf-button> | ||
<pf-dropdown-menu slot="menu"> | ||
<pf-dropdown-item>item4</pf-dropdown-item> | ||
<hr> | ||
<pf-dropdown-group label="Group 1"> | ||
<pf-dropdown-item>item1</pf-dropdown-item> | ||
<pf-dropdown-item>item2</pf-dropdown-item> | ||
<hr> | ||
<pf-dropdown-item>item3</pf-dropdown-item> | ||
</pf-dropdown-group> | ||
<pf-dropdown-group label="Group 2"> | ||
<pf-dropdown-item>item1</pf-dropdown-item> | ||
<pf-dropdown-item>item2</pf-dropdown-item> | ||
<pf-dropdown-item>item3</pf-dropdown-item> | ||
<pf-dropdown-item disabled>disabled</pf-dropdown-item> | ||
</pf-dropdown-group> | ||
</pf-dropdown-menu> | ||
</pf-dropdown> | ||
|
||
<pf-dropdown id="icon"> | ||
<pf-button plain slot="toggle" icon="ellipsis-v" label="Icon toggle"></pf-button> | ||
<pf-dropdown-menu slot="menu"> | ||
<pf-dropdown-item>item4</pf-dropdown-item> | ||
<hr> | ||
<pf-dropdown-group label="Group 1"> | ||
<pf-dropdown-item>item1</pf-dropdown-item> | ||
<pf-dropdown-item>item2</pf-dropdown-item> | ||
<hr> | ||
<pf-dropdown-item>item3</pf-dropdown-item> | ||
</pf-dropdown-group> | ||
<pf-dropdown-group label="Group 2"> | ||
<pf-dropdown-item>item1</pf-dropdown-item> | ||
<pf-dropdown-item>item2</pf-dropdown-item> | ||
<pf-dropdown-item>item3</pf-dropdown-item> | ||
<pf-dropdown-item disabled>disabled</pf-dropdown-item> | ||
</pf-dropdown-group> | ||
</pf-dropdown-menu> | ||
</pf-dropdown> | ||
|
||
<script type="module"> | ||
import '@patternfly/elements/pf-dropdown/pf-dropdown.js'; | ||
import '@patternfly/elements/pf-switch/pf-switch.js'; | ||
const sw = document.getElementById('disable-all') | ||
sw.addEventListener('click', function() { | ||
document.querySelectorAll('main pf-dropdown').forEach(x => x.disabled = sw.checked); | ||
}) | ||
</script> | ||
|
||
|
||
<style> | ||
#switch-group { | ||
display: inline-flex; | ||
justify-content: center; | ||
vertical-align: middle; | ||
gap: 8px; | ||
} | ||
</style> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.