-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
#4401 ## Category
- Question
- Typo
- Bug
- Additional article idea
Expected or Desired Behavior
I'm trying to have an async check on command visibility as my conditions are:
- only one item selected (sync and easy)
- two properties (not in the list view) on the item must have required values (async call needed)
- the user must belong to a particular group (async in the onInit easy)
So I need to make requests in the onListViewUpdated(event) method to determine whether or not I should display my command. I'm expecting the myCommand.visible = true to work within a promise or callback.
Observed Behavior
Whenever I leave the synchronous thread, any action on the command visibility doesn't work:
setTimeout(() => command.visible = true)fetch('w/e').then(r => r.json()).then(r => command.visible = r.display)
I've tried the this.tryGetCommand('myCommand') at the beginning of the method and inside the asynchronous call without any success what so ever.
I've also tried to find a method to force render but we don't seem to have any control over that.
Steps to Reproduce
just have this
public onListViewUpdated(event: IListViewCommandSetListViewUpdatedParameters): void {
var myCommand: Command = this.tryGetCommand('MY_COMMAND');
setTimeout(function () {
myCommand.visible = true
}, 1000)
}
where MY_COMMAND is your existing command.
I'm actually open to any suggestion to go around that. The only async call that I actually need is to check the properties of the selected item (and i don't have them since the event.selectedRows[0].getValueByName('my-field') doesn't garantee the presence of fields).
What I would expect would be that the onListViewUpdated returns a Promise<void> just like the onInit() to actually support asynchronous conditions.
What I gather from the current state is that no command can have async checking on selection, which will compel me in my case to display a command, only to display a panel saying that the item doesn't have the proper values to actually do anything.