Skip to content

(Picker) Fix OnChange event for AutoHeight change not firing in custom pages #32

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

Merged
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
9 changes: 5 additions & 4 deletions Picker/Picker/TagPickerComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export interface TagPickerComponentProps {
onAdd: (item: ITag) => void;
filterSuggestions: (search: string) => Promise<ITag[]> | ITag[];
onResize?: (width: number, height: number) => void;
minumumFilterLength: number | null;
minimumFilterLength: number | null;
keepTypingMessage: string | null;
noSuggestionsMessage: string | null;
maxTags: number | undefined;
Expand Down Expand Up @@ -86,7 +86,7 @@ export const TagPickerComponent = React.memo((props: TagPickerComponentProps) =>
onRemove,
onAdd,
filterSuggestions,
minumumFilterLength,
minimumFilterLength,
keepTypingMessage,
noSuggestionsMessage,
maxTags,
Expand Down Expand Up @@ -141,6 +141,7 @@ export const TagPickerComponent = React.memo((props: TagPickerComponentProps) =>
// This is needed for custom pages to ensure the Tag Picker grows to the full width
return {
width: width,
height: 'fit-content',
} as React.CSSProperties;
}, [width]);

Expand Down Expand Up @@ -257,11 +258,11 @@ export const TagPickerComponent = React.memo((props: TagPickerComponentProps) =>
const pickerSuggestionsProps: IBasePickerSuggestionsProps = React.useMemo(() => {
return {
noResultsFoundText:
searchTerm && minumumFilterLength && searchTerm.length < minumumFilterLength
searchTerm && minimumFilterLength && searchTerm.length < minimumFilterLength
? (keepTypingMessage as string)
: (noSuggestionsMessage as string),
};
}, [searchTerm, keepTypingMessage, noSuggestionsMessage, minumumFilterLength]);
}, [searchTerm, keepTypingMessage, noSuggestionsMessage, minimumFilterLength]);

const target = React.useRef<HTMLElement>(null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`Picker renders 1`] = `
className="PowerCATTagPicker"
style={
Object {
"height": "fit-content",
"width": -1,
}
}
Expand Down Expand Up @@ -142,6 +143,7 @@ exports[`Picker renders with simple tags 1`] = `
className="PowerCATTagPicker"
style={
Object {
"height": "fit-content",
"width": -1,
}
}
Expand Down Expand Up @@ -281,7 +283,7 @@ exports[`Picker renders with simple tags 1`] = `
background: #0078d4;
color: #ffffff;
}
@media screen and (-ms-high-contrast: active), (forced-colors: active){& {
@media screen and (-ms-high-contrast: active), screen and (forced-colors: active){& {
border: 1px solid WindowText;
}
role="listitem"
Expand Down Expand Up @@ -351,7 +353,7 @@ exports[`Picker renders with simple tags 1`] = `
top: 2px;
z-index: 1;
}
@media screen and (-ms-high-contrast: active), (forced-colors: active){.ms-Fabric--isFocusVisible &:focus:after {
@media screen and (-ms-high-contrast: active), screen and (forced-colors: active){.ms-Fabric--isFocusVisible &:focus:after {
bottom: -2px;
left: -2px;
outline-color: ButtonText;
Expand All @@ -368,7 +370,7 @@ exports[`Picker renders with simple tags 1`] = `
background: #e1dfdd;
color: #323130;
}
@media screen and (-ms-high-contrast: active), (forced-colors: active){&:hover {
@media screen and (-ms-high-contrast: active), screen and (forced-colors: active){&:hover {
border-color: Highlight;
color: Highlight;
}
Expand Down Expand Up @@ -483,7 +485,7 @@ exports[`Picker renders with simple tags 1`] = `
background: #0078d4;
color: #ffffff;
}
@media screen and (-ms-high-contrast: active), (forced-colors: active){& {
@media screen and (-ms-high-contrast: active), screen and (forced-colors: active){& {
border: 1px solid WindowText;
}
role="listitem"
Expand Down Expand Up @@ -553,7 +555,7 @@ exports[`Picker renders with simple tags 1`] = `
top: 2px;
z-index: 1;
}
@media screen and (-ms-high-contrast: active), (forced-colors: active){.ms-Fabric--isFocusVisible &:focus:after {
@media screen and (-ms-high-contrast: active), screen and (forced-colors: active){.ms-Fabric--isFocusVisible &:focus:after {
bottom: -2px;
left: -2px;
outline-color: ButtonText;
Expand All @@ -570,7 +572,7 @@ exports[`Picker renders with simple tags 1`] = `
background: #e1dfdd;
color: #323130;
}
@media screen and (-ms-high-contrast: active), (forced-colors: active){&:hover {
@media screen and (-ms-high-contrast: active), screen and (forced-colors: active){&:hover {
border-color: Highlight;
color: Highlight;
}
Expand Down Expand Up @@ -685,7 +687,7 @@ exports[`Picker renders with simple tags 1`] = `
background: #0078d4;
color: #ffffff;
}
@media screen and (-ms-high-contrast: active), (forced-colors: active){& {
@media screen and (-ms-high-contrast: active), screen and (forced-colors: active){& {
border: 1px solid WindowText;
}
role="listitem"
Expand Down Expand Up @@ -755,7 +757,7 @@ exports[`Picker renders with simple tags 1`] = `
top: 2px;
z-index: 1;
}
@media screen and (-ms-high-contrast: active), (forced-colors: active){.ms-Fabric--isFocusVisible &:focus:after {
@media screen and (-ms-high-contrast: active), screen and (forced-colors: active){.ms-Fabric--isFocusVisible &:focus:after {
bottom: -2px;
left: -2px;
outline-color: ButtonText;
Expand All @@ -772,7 +774,7 @@ exports[`Picker renders with simple tags 1`] = `
background: #e1dfdd;
color: #323130;
}
@media screen and (-ms-high-contrast: active), (forced-colors: active){&:hover {
@media screen and (-ms-high-contrast: active), screen and (forced-colors: active){&:hover {
border-color: Highlight;
color: Highlight;
}
Expand Down
2 changes: 1 addition & 1 deletion Picker/Picker/__tests__/tag-picker-component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const defaultProps = {
height: 32,
tags: [] as ITag[],
tabIndex: 1,
minumumFilterLength: 0,
minimumFilterLength: 0,
keepTypingMessage: null,
noSuggestionsMessage: null,
maxTags: undefined,
Expand Down
16 changes: 8 additions & 8 deletions Picker/Picker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export class Picker implements ComponentFramework.ReactControl<IInputs, IOutputs
resources: ComponentFramework.Resources;
tags: ITagItem[];
isFullScreen = false;
tagEvent: string | undefined;
tagDisplayName: string | undefined;
tagKey: string | undefined;
tagEvent = '';
tagDisplayName: string | undefined = '';
tagKey: string | undefined = '';
suggestions: ITagItem[];
searchText: string;
previousSearchText: string;
Expand Down Expand Up @@ -137,7 +137,7 @@ export class Picker implements ComponentFramework.ReactControl<IInputs, IOutputs
onAdd: this.addTag,
onRemove: this.removeTag,
filterSuggestions: this.filterSuggestions,
minumumFilterLength: this.context.parameters.MinimumSearchTermLength.raw,
minimumFilterLength: this.context.parameters.MinimumSearchTermLength.raw,
keepTypingMessage: this.context.parameters.SearchTermToShortMessage.raw,
noSuggestionsMessage: this.context.parameters.NoSuggestionFoundMessage.raw,
maxTags: this.undefinedIfZero(this.context.parameters.MaxTags),
Expand Down Expand Up @@ -179,8 +179,8 @@ export class Picker implements ComponentFramework.ReactControl<IInputs, IOutputs
const keyIndex: Record<string, number> = {};
return tagsDataset.sortedRecordIds.map((id) => {
const record = tagsDataset.records[id];
const recordid = record.getRecordId();
let key = (record.getValue(TagsColumns.TagsKey) as string) ?? recordid;
const recordId = record.getRecordId();
let key = (record.getValue(TagsColumns.TagsKey) as string) ?? recordId;
// Prevent duplicate keys by appending the duplicate index
if (keyIndex[key] !== undefined) {
keyIndex[key]++;
Expand All @@ -206,8 +206,8 @@ export class Picker implements ComponentFramework.ReactControl<IInputs, IOutputs
const keyIndex: Record<string, number> = {};
return suggestionsDataset.sortedRecordIds.map((id) => {
const record = suggestionsDataset.records[id];
const recordid = record.getRecordId();
let key = (record.getValue(SuggestionsColumns.SuggestionKey) as string) ?? recordid;
const recordId = record.getRecordId();
let key = (record.getValue(SuggestionsColumns.SuggestionKey) as string) ?? recordId;
// Prevent duplicate keys by appending the duplicate index
if (keyIndex[key] !== undefined) {
keyIndex[key]++;
Expand Down
Loading