Skip to content
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

[BUG]: DetailsList Selected property not blanked when removing selected record #451

Open
e-gallis opened this issue Mar 6, 2024 · 5 comments
Assignees
Labels
bug Something isn't working code Issue is related to a Power Apps code component Component: DetailsList 👋 needs author feedback Waiting on a response from the author

Comments

@e-gallis
Copy link

e-gallis commented Mar 6, 2024

Describe the bug
After removing a selected record from the list's records, the Selected property still holds the data of the deleted record.

To Reproduce
Steps to reproduce the behavior:

  1. Add a DetailsList control to the screen
  2. Provide the control with a set of records through a collection
  3. Add a button on the screen with a piece of code to remove the selected record from the collection
  4. The record is removed from the list but the Selected property still holds the deleted record

Expected behavior
The Selected property should be cleared if the currently selected record is removed from the list (that is, when no records are selected)

Screenshots
N/A

Additional context
N/A

AB#2489

@e-gallis e-gallis added bug Something isn't working ⚠️ needs triage Has not been triaged by the team yet. labels Mar 6, 2024
@e-gallis
Copy link
Author

e-gallis commented Mar 6, 2024

Anyone with any idea on how to workaround this issue meanwhile?

@denise-msft denise-msft added this to the Creator Kit - May 2024 milestone May 1, 2024
@denise-msft
Copy link
Member

@e-gallis would it work to update the collection to 'reset' after deletion by selecting the first item in the list instead of clearing out? Have you tried that scenario, or would there be any reason why that is inappropriate for your workflow?

@denise-msft denise-msft self-assigned this Jun 18, 2024
@denise-msft denise-msft added 👋 needs author feedback Waiting on a response from the author and removed ⚠️ needs triage Has not been triaged by the team yet. labels Jun 18, 2024
@e-gallis
Copy link
Author

Hi @denise-msft,
Indeed this would be inappropriate. Here is my scenario:

  • I have a DetailsList component listing a set of records from a collection
  • The application allows me to delete a selected record
  • After the record has been removed from the collection there should be no more record selected -> therefore I expect the Selected property to be blank
    You can find the same behavior on Microsoft Lists: deleting an item does not select the first item in the list after deletion. There is just no other item selected.
    I expect the same from the DetailsList component. Well, I suppose it is a "standard behavior" throughout web applications in general.
    Hope this helps... 😉

@denise-msft
Copy link
Member

@e-gallis we are unable to reproduce this issue. Is this issue still happening for you in the latest version of the Creator Kit?

Can you please provide the code you're using to remove the record? Also, are you binding directly to a table or using a local collection? And are you implementing the set row selection capability at all, or is this just a basic Remove() operation?

If you bind the detailsList directly to the table (e.g., Dataverse Accounts table) and use a button to remove the selected record (e.g., Remove(Accounts, FluentDetailsList1.Selected);) then this should work as expected/what you described.

@denise-msft
Copy link
Member

@e-gallis we are able to reproduce this. We'll evaluate if this is expected behavior and if there's a better pattern, or if it's an issue with the implementation.

One workaround you could consider is using a global or context variable to hold the value of the selected item using Self.Selected.Id or some column on the table to indicate that a value is being selected, and then set that variable to blank() when deleting. For example, in the DetailsList.OnChange property, UpdateContext({ selectedItem: Self.Selected.Id }); - then on Delete, add UpdateContext({ selectedItem: Blank() });

@denise-msft denise-msft added code Issue is related to a Power Apps code component Component: DetailsList labels Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working code Issue is related to a Power Apps code component Component: DetailsList 👋 needs author feedback Waiting on a response from the author
Projects
None yet
Development

No branches or pull requests

2 participants