microsoft-graph-toolkit

Graph Toolkit - mgt-picker and mgt-channel-picker - Clear the selected value


Once user select the channel or value in mgt-channel-picker or mgt-picker, there is no way to clean the selected value on any event using javascript.

I can ofcourse target the 'X' icon and click on it using Javascript, but will be good if this can be handle with graph toolkit. Is there any way?

enter image description here


Solution

  • For mgt-picker you can set the value of the selected-value attribute or the selectedValue property of the element:

    const button = document.querySelector('button');
    button.addEventListener('click', () =>{
        const picker = document.querySelector('mgt-picker');
        picker.selectedValue = "";
        console.log('clear selection');
    });
    

    For mgt-teams-channel-picker this is a gap in our current implementation. Could you please raise an issue on the repo to track this?