-
Notifications
You must be signed in to change notification settings - Fork 77
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
feat(value-list-item): add new slot labelled as content-center to replace label/description (#3373) #3579
feat(value-list-item): add new slot labelled as content-center to replace label/description (#3373) #3579
Changes from all commits
97b6fa6
b7b7d6b
5234a28
2b620d2
3260150
592e7e2
77a25a3
bcc9914
8b050b1
9adb284
45dea00
7d01e5b
c88bb11
046b914
cc70156
c828c27
731edd8
14069d8
040d3ce
3e516e6
0f21fcb
f6d69f7
7a24d68
795e018
b27ce13
4083612
c519f56
5f39db5
7526d00
5db919d
71881c7
2bec25e
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 |
---|---|---|
|
@@ -17,6 +17,7 @@ import { getSlotted } from "../../utils/dom"; | |
/** | ||
* @slot actions-end - a slot for adding actions or content to the end side of the item. | ||
* @slot actions-start - a slot for adding actions or content to the start side of the item. | ||
* @slot content - a slot for adding content at the center of the item and it will take precedence over label prop if utilized. | ||
*/ | ||
@Component({ | ||
tag: "calcite-pick-list-item", | ||
|
@@ -127,7 +128,7 @@ export class CalcitePickListItem { | |
|
||
@Element() el: HTMLCalcitePickListItemElement; | ||
|
||
private focusEl: HTMLLabelElement; | ||
private focusEl: HTMLLabelElement | HTMLDivElement; | ||
|
||
shiftPressed: boolean; | ||
|
||
|
@@ -270,6 +271,46 @@ export class CalcitePickListItem { | |
) : null; | ||
} | ||
|
||
renderContent(): VNode { | ||
const { description, label, el } = this; | ||
const hasContentSlot = getSlotted(el, SLOTS.content); | ||
|
||
return hasContentSlot ? ( | ||
<div class={CSS.content}> | ||
<div | ||
aria-checked={this.selected.toString()} | ||
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 checkbox role element is missing a label. Can you verify this passes aXe? Can we add an updated 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. Can we just keep the existing
|
||
class={CSS.contentSelect} | ||
onClick={this.pickListClickHandler} | ||
onKeyDown={this.pickListKeyDownHandler} | ||
ref={(focusEl): HTMLDivElement => (this.focusEl = focusEl)} | ||
role="menuitemcheckbox" | ||
tabIndex={0} | ||
/> | ||
<div class={CSS.contentSlot}> | ||
<slot name={SLOTS.content} /> | ||
</div> | ||
</div> | ||
) : ( | ||
<label | ||
aria-label={label} | ||
class={CSS.label} | ||
onClick={this.pickListClickHandler} | ||
onKeyDown={this.pickListKeyDownHandler} | ||
ref={(focusEl): HTMLLabelElement => (this.focusEl = focusEl)} | ||
tabIndex={0} | ||
> | ||
<div | ||
aria-checked={this.selected.toString()} | ||
y0n4 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
class={CSS.textContainer} | ||
role="menuitemcheckbox" | ||
> | ||
<span class={CSS.title}>{label}</span> | ||
{description ? <span class={CSS.description}>{description}</span> : null} | ||
</div> | ||
</label> | ||
); | ||
} | ||
|
||
renderActionsEnd(): VNode { | ||
const { el, removable } = this; | ||
const hasActionsEnd = getSlotted(el, SLOTS.actionsEnd); | ||
|
@@ -283,29 +324,11 @@ export class CalcitePickListItem { | |
} | ||
|
||
render(): VNode { | ||
const { description, label } = this; | ||
|
||
return ( | ||
<Fragment> | ||
{this.renderIcon()} | ||
{this.renderActionsStart()} | ||
<label | ||
aria-label={label} | ||
class={CSS.label} | ||
onClick={this.pickListClickHandler} | ||
onKeyDown={this.pickListKeyDownHandler} | ||
ref={(focusEl): HTMLLabelElement => (this.focusEl = focusEl)} | ||
tabIndex={0} | ||
> | ||
<div | ||
aria-checked={this.selected.toString()} | ||
class={CSS.textContainer} | ||
role="menuitemcheckbox" | ||
> | ||
<span class={CSS.title}>{label}</span> | ||
{description ? <span class={CSS.description}>{description}</span> : null} | ||
</div> | ||
</label> | ||
{this.renderContent()} | ||
{this.renderActionsEnd()} | ||
</Fragment> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,6 +105,23 @@ export const basic = (): string => | |
` | ||
); | ||
|
||
export const withContentSlot = (): string => | ||
create( | ||
"calcite-value-list", | ||
createAttributes(), | ||
html` | ||
<calcite-value-list-item label="Default label and description" description="used as content" value="dogs"> | ||
${action} | ||
</calcite-value-list-item> | ||
<calcite-value-list-item value="cats"> | ||
<div slot="content"> | ||
<calcite-input placeholder="slot content"></calcite-input> | ||
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. I think this will be problematic, the role of the list-item is a checkbox. The checkbox can't contain an input inside of it I don't think. The DOM structure and roles would need to be reconfigured. Can we make sure that this HTML passes aXe? |
||
</div> | ||
${action} | ||
</calcite-value-list-item> | ||
` | ||
); | ||
|
||
export const darkThemeRTL = (): string => | ||
create( | ||
"calcite-value-list", | ||
|
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.
@asangma @y0n4 why is this positioned absolutely?
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.
I did absolute position for the selected portion of the item in relative to the current content. That way users can have the choice to focus on the item itself or the content within. This is to escape the events from bubbling up and an alternative to the stopPropagation method.