问题
When a user tabs into a List and the List gets focus I want to put a border around the List's parent. It would be great if I could call onFocus/onBlur on the List. Any advice?
回答1:
Currently there is no way to attach onBlur
or onFocus
events (or anything other than onScroll
) to a Grid
. (The same is true for List
which just decorates a Grid
).
You could add this behavior yourself using the ref
though. Here is an example Plnkr: https://plnkr.co/edit/TVxnhf?p=preview
The key part is:
_setListRef(listRef) {
if (listRef) {
listRef = findDOMNode(listRef);
listRef.addEventListener('blur', onListBlur);
listRef.addEventListener('focus', onListFocus);
}
}
来源:https://stackoverflow.com/questions/44188298/react-virtualized-notification-when-list-gets-focus