mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-21 22:54:11 +08:00
Fix thread selection with cmd
and shift
keys in the thread list
Summary: We recently added a `shouldComponentUpdate` method to ListTabular to improve scrolling performance. However, this was preventing ListTabular from updating the selected state of its items when we selected new threads via cmd or shift keys. This occurred because instead of passing data as props for each of ListTabular's items, we are passing a function that calculates the props for each item, so when we diffed old props and new props in shouldComponentUpdate, given that the function reference never changes, we thought that the props hadn't changed and prevented a re render, when in fact the props for each item generated by that function might actually change. Unfortunately, we can't use shouldComponentUpdate in this component given how it is structured Test Plan: manual Reviewers: evan, spang, halla Reviewed By: spang Differential Revision: https://phab.nylas.com/D3837
This commit is contained in:
parent
8f241048de
commit
e49e3c5ad3
1 changed files with 11 additions and 13 deletions
|
@ -38,10 +38,6 @@ class ListTabular extends React.Component
|
|||
@setupDataSource(@props.dataSource)
|
||||
@updateRangeState()
|
||||
|
||||
shouldComponentUpdate: (nextProps, nextState) =>
|
||||
not Utils.isEqualReact(nextProps, @props) or
|
||||
not Utils.isEqualReact(nextState, @state)
|
||||
|
||||
componentWillUnmount: =>
|
||||
window.removeEventListener('resize', @onWindowResize, true)
|
||||
window.clearTimeout(@_cleanupAnimationTimeout) if @_cleanupAnimationTimeout
|
||||
|
@ -211,15 +207,17 @@ class ListTabular extends React.Component
|
|||
|
||||
_rowForItem: (item, idx) =>
|
||||
return false unless item
|
||||
<ListTabularItem key={item.id ? idx}
|
||||
item={item}
|
||||
itemProps={@props.itemPropsProvider?(item, idx) ? {}}
|
||||
metrics={top: idx * @props.itemHeight, height: @props.itemHeight}
|
||||
columns={@props.columns}
|
||||
onSelect={@props.onSelect}
|
||||
onClick={@props.onClick}
|
||||
onReorder={@props.onReorder}
|
||||
onDoubleClick={@props.onDoubleClick} />
|
||||
<ListTabularItem
|
||||
key={item.id ? idx}
|
||||
item={item}
|
||||
itemProps={@props.itemPropsProvider?(item, idx) ? {}}
|
||||
metrics={top: idx * @props.itemHeight, height: @props.itemHeight}
|
||||
columns={@props.columns}
|
||||
onSelect={@props.onSelect}
|
||||
onClick={@props.onClick}
|
||||
onReorder={@props.onReorder}
|
||||
onDoubleClick={@props.onDoubleClick}
|
||||
/>
|
||||
|
||||
# Public: Scroll to the DOM node provided.
|
||||
#
|
||||
|
|
Loading…
Reference in a new issue