Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
Comment thread
bsunderhus marked this conversation as resolved.
"type": "minor",
"comment": "feat: adds text property to TagPickerOption",
"packageName": "@fluentui/react-tag-picker",
"email": "bernardo.sunderhus@gmail.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,14 @@ export type TagPickerOptionGroupState = OptionGroupState;

// @public
export type TagPickerOptionProps = ComponentProps<TagPickerOptionSlots> & {
children: React_2.ReactNode;
value: string;
};
} & ({
text?: string;
children: string;
} | {
text: string;
children?: React_2.ReactNode;
});

// @public (undocumented)
export type TagPickerOptionSlots = Pick<OptionSlots, 'root'> & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import * as React from 'react';
import { render } from '@testing-library/react';
import { isConformant } from '../../testing/isConformant';
import { TagPickerOption } from './TagPickerOption';
import { TagPickerOptionProps } from './TagPickerOption.types';

describe('TagPickerOption', () => {
isConformant({
isConformant<TagPickerOptionProps>({
Component: TagPickerOption,
displayName: 'TagPickerOption',
requiredProps: { value: 'value', media: <></>, secondaryContent: <></> },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,28 @@ export type TagPickerOptionSlots = Pick<OptionSlots, 'root'> & {
* TagPickerOption Props
*/
export type TagPickerOptionProps = ComponentProps<TagPickerOptionSlots> & {
children: React.ReactNode;
value: string;
};
} & (
| {
/**
* An optional override the string value of the Option's display text,
* defaulting to the Option's child content.
* This is used as the Dropdown button's or Combobox input's value when the option is selected,
* and as the comparison for type-to-find keyboard functionality.
*/
text?: string;
children: string;
}
| {
/**
* The string value of the Option's display text when the Option's children are not a string.
* This is used as the Dropdown button's or Combobox input's value when the option is selected,
* and as the comparison for type-to-find keyboard functionality.
*/
text: string;
children?: React.ReactNode;
}
);

/**
* State used in rendering TagPickerOption
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { slot } from '@fluentui/react-utilities';
import { OptionProps, useOption_unstable } from '@fluentui/react-combobox';
import { useOption_unstable } from '@fluentui/react-combobox';
import type { TagPickerOptionProps, TagPickerOptionState } from './TagPickerOption.types';

/**
Expand All @@ -16,7 +16,7 @@ export const useTagPickerOption_unstable = (
props: TagPickerOptionProps,
ref: React.Ref<HTMLDivElement>,
): TagPickerOptionState => {
const optionState = useOption_unstable(props as OptionProps, ref);
const optionState = useOption_unstable(props, ref);
const state: TagPickerOptionState = {
components: {
...optionState.components,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export const TruncatedText = () => {
value={option.value}
key={option.value}
title={option.value}
text={option.value}
>
<div className={styles.optionContent}>{option.value}</div>
</TagPickerOption>
Expand Down