【问题标题】:react-virtualized notification when List gets focusList 获得焦点时的反应虚拟化通知
【发布时间】:2017-10-26 13:32:08
【问题描述】:

当用户进入列表并且列表获得焦点时,我想在列表的父级周围放置一个边框。如果我能在 List 上调用 onFocus/onBlur 那就太好了。有什么建议吗?

【问题讨论】:

    标签: react-virtualized


    【解决方案1】:

    目前无法将onBluronFocus 事件(或onScroll 以外的任何事件)附加到Grid。 (List 也是如此,它只是装饰了一个Grid)。

    您可以使用ref 自己添加此行为。这是一个 Plnkr 示例:https://plnkr.co/edit/TVxnhf?p=preview

    关键部分是:

      _setListRef(listRef) {
        if (listRef) {
          listRef = findDOMNode(listRef);
          listRef.addEventListener('blur', onListBlur);
          listRef.addEventListener('focus', onListFocus);
        }
      }
    

    【讨论】:

    • 哇——完美。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 2018-10-20
    • 1970-01-01
    • 1970-01-01
    • 2011-12-06
    • 1970-01-01
    • 1970-01-01
    • 2021-09-03
    • 2018-01-23
    相关资源
    最近更新 更多