Looking at the docs:
https://dev.office.com/fabric#/components/commandbar
It seems like the Command Bar's search
feature has no trigger command built in. Which is kind of odd, not sure how we're supposed to use a searchbox with no onSearch
callback!
For now I'm just using this as a workaround:
public componentDidMount() {
let searchBox = document.querySelectorAll(".parentContainer .ms-CommandBarSearch-input");
if (searchBox.length) {
let inputBox = searchBox.item(0) as HTMLInputElement;
inputBox.onkeydown = (e: Event) => {
// Do Search
}
}
}
I might have missed something here, so let me know if that's the case. Otherwise I have a feature request: add an onSearch
property to the command bar.
We have plans to replace the command bar search bar with our search component. So if you have a working workaround we probably won't fix this.
Any news on this matter ?
Any updates regarding onSearch()
?
in Fabric 6.0 (in beta now, and soon to be released) you'll be able to drop in your own searchbox with all of the necessary searchbox props. This old approach is being deprecated (as it never worked anyway)
Most helpful comment
Any news on this matter ?