Skip to content

Commit

Permalink
Allow title to be provided to Select.Option
Browse files Browse the repository at this point in the history
  • Loading branch information
acelaya committed Oct 29, 2024
1 parent 7fc3e67 commit b48339a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/input/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export type SelectOptionProps<T> = {

/** Ref associated with the option's container element */
elementRef?: Ref<HTMLElement | undefined>;
/** Value to be passed to the option's `title` attribute */
title?: string;
};

function optionChildren(
Expand All @@ -70,6 +72,7 @@ function SelectOption<T>({
disabled = false,
classes,
elementRef,
title,
}: SelectOptionProps<T>) {
const checkboxRef = useRef<HTMLElement | null>(null);
const checkboxContainerRef = useRef<HTMLLabelElement | null>(null);
Expand Down Expand Up @@ -187,6 +190,7 @@ function SelectOption<T>({
// This is intended to be focused with arrow keys
tabIndex={-1}
ref={downcastRef(optionRef)}
title={title}
>
<div
className={classnames(
Expand Down
14 changes: 14 additions & 0 deletions src/pattern-library/components/patterns/prototype/SelectPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,20 @@ export default function SelectPage() {
</Library.InfoItem>
</Library.Info>
</Library.Example>
<Library.Example title="title">
<Library.Info>
<Library.InfoItem label="description">
If provided, it is set as the option{"'"}s <code>title</code>{' '}
attribute.
</Library.InfoItem>
<Library.InfoItem label="type">
<code>string | undefined</code>
</Library.InfoItem>
<Library.InfoItem label="default">
<code>undefined</code>
</Library.InfoItem>
</Library.Info>
</Library.Example>
</Library.Pattern>
</Library.Section>

Expand Down

0 comments on commit b48339a

Please sign in to comment.