microsoft / powercat-creator-kit

This toolkit helps create well-designed Power App experiences on the web & mobile. It contains a component library; PCF controls and other utilities that increase developer productivity.
MIT License
296 stars 49 forks source link

[BUG]: Picker Add event does not give TagKey, does not allow quick entry, slow to update #439

Open Universezero opened 6 months ago

Universezero commented 6 months ago

Describe the bug There seems to be a number of problems with the Picker that makes it fairly unusable for me, despite there not seeming to be any alternative control in PowerApps that provides the same functionality.

First off, the documentation for the Picker is incorrect. It says that TagsDisplayName is "the text that is used to create a new Tag when the On Change event is fired", but this is not true - it's the label from your item collection that is used as the text for the tags. Which means that to add an item to your item collection when it's entered, the only way I can seem to capture this value is through SearchTerm, since the Add event does not supply a TagKey if the typed item is not in the suggestion collection. However, I've found that if I type quickly (i.e. type in text, then quickly hit enter), the SearchTerm is blank. This makes it impossible to quickly type lots of items into the Picker, which you can do if the Picker Items is not tied to a collection - however, without a collection, the data cannot be captured.

Additionally, working with a collection seems to make the picker very slow - I remove an item, and it takes 1000 milliseconds or more to remove it. Same goes for adding.

I thought I might be able to get around this behaviour by simply not providing an Items collection, and adding/removing items from a separate collection through the OnChange. However, the Picker doesn't fire ANY Add or Remove TagEvents if it doesn't have a Items collection! It would be great if it did, since without an Items collection the Picker actually works quickly to add and remove items.

To Reproduce Steps to reproduce the behavior:

  1. Add a Picker
  2. Set onChange to this code: `Set(event, "TagEvent: " & Self.TagEvent & Char(10) & "TagKey: " & Self.TagKey & Char(10) & "SearchTerm: " & Self.SearchTerm & Char(10) & "TagsDisplayName: " & Self.TagsDisplayName);

If(Self.TagEvent = "Add", With({selection: If(IsBlank(Self.TagKey), Self.SearchTerm, Self.TagKey)}, If(!IsBlank(selection) && IsBlank(LookUp(col_Tags, Value = selection)), Collect( col_Tags, {Value: selection} ) ) ) );

If(Self.TagEvent = "Remove", RemoveIf( col_Tags, Value = Text(Self.TagKey) ) );`

  1. Set Items to 'col_Tags', and TagsKey and TagsDisplayName both to "Value"
  2. Add a text label with variable 'event' as the text (helps to show the issues)
  3. Add/remove items, both quickly and with a delay in hitting enter

Expected behavior Should be able to add/remove items to and from the Picker quickly.

AB#1685

Universezero commented 6 months ago

Additionally, it would be great if the items in the Picker could be accessed via something like Picker.SelectedItems (since SelectedItems is a part of the Picker, but is always blank) as a way of easily accessing the Picker data rather than having to faff about with managing a collection.

denise-msft commented 4 months ago

Thanks for your feedback @Universezero. We will investigate this and address as resources permit.