-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor/align selectionlist checkboxes #37402
Changes from all commits
66a4c0a
ad6aa38
ee31536
645a1a4
2e1472b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ function BaseListItem<TItem extends ListItem>({ | |
shouldPreventDefaultFocusOnSelectRow = false, | ||
canSelectMultiple = false, | ||
onSelectRow, | ||
onCheckboxPress, | ||
onDismissError = () => {}, | ||
rightHandSideComponent, | ||
keyForList, | ||
|
@@ -43,6 +44,14 @@ function BaseListItem<TItem extends ListItem>({ | |
return rightHandSideComponent; | ||
}; | ||
|
||
const handleCheckboxPress = () => { | ||
if (onCheckboxPress) { | ||
onCheckboxPress(item); | ||
} else { | ||
onSelectRow(item); | ||
} | ||
}; | ||
|
||
return ( | ||
<OfflineWithFeedback | ||
onClose={() => onDismissError(item)} | ||
|
@@ -66,8 +75,10 @@ function BaseListItem<TItem extends ListItem>({ | |
<> | ||
<View style={wrapperStyle}> | ||
{canSelectMultiple && ( | ||
<View | ||
<PressableWithFeedback | ||
accessibilityLabel={item.text} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a minor regression: regression.mp4we also need to pass There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, I noticed that as well. Btw not blocker since admin cannot be actually removed. |
||
role={CONST.ROLE.BUTTON} | ||
onPress={handleCheckboxPress} | ||
style={StyleUtils.getCheckboxPressableStyle()} | ||
> | ||
<View style={selectMultipleStyle}> | ||
|
@@ -80,7 +91,7 @@ function BaseListItem<TItem extends ListItem>({ | |
/> | ||
)} | ||
</View> | ||
</View> | ||
</PressableWithFeedback> | ||
)} | ||
|
||
{typeof children === 'function' ? children(hovered) : children} | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -8,7 +8,6 @@ import Button from '@components/Button'; | |||||
import Checkbox from '@components/Checkbox'; | ||||||
import FixedFooter from '@components/FixedFooter'; | ||||||
import OptionsListSkeletonView from '@components/OptionsListSkeletonView'; | ||||||
import PressableWithFeedback from '@components/Pressable/PressableWithFeedback'; | ||||||
import SafeAreaConsumer from '@components/SafeAreaConsumer'; | ||||||
import SectionList from '@components/SectionList'; | ||||||
import Text from '@components/Text'; | ||||||
|
@@ -30,6 +29,7 @@ function BaseSelectionList<TItem extends ListItem>( | |||||
ListItem, | ||||||
canSelectMultiple = false, | ||||||
onSelectRow, | ||||||
onCheckboxPress, | ||||||
onSelectAll, | ||||||
onDismissError, | ||||||
textInputLabel = '', | ||||||
|
@@ -289,6 +289,7 @@ function BaseSelectionList<TItem extends ListItem>( | |||||
showTooltip={showTooltip} | ||||||
canSelectMultiple={canSelectMultiple} | ||||||
onSelectRow={() => selectRow(item)} | ||||||
onCheckboxPress={onCheckboxPress ? () => onCheckboxPress?.(item) : undefined} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NAB:
Suggested change
|
||||||
onDismissError={() => onDismissError?.(item)} | ||||||
shouldPreventDefaultFocusOnSelectRow={shouldPreventDefaultFocusOnSelectRow} | ||||||
rightHandSideComponent={rightHandSideComponent} | ||||||
|
@@ -429,28 +430,19 @@ function BaseSelectionList<TItem extends ListItem>( | |||||
) : ( | ||||||
<> | ||||||
{!headerMessage && canSelectMultiple && shouldShowSelectAll && ( | ||||||
<PressableWithFeedback | ||||||
style={[styles.peopleRow, styles.userSelectNone, styles.ph4, styles.pb3, listHeaderWrapperStyle]} | ||||||
onPress={selectAllRow} | ||||||
accessibilityLabel={translate('workspace.people.selectAll')} | ||||||
role="button" | ||||||
accessibilityState={{checked: flattenedSections.allSelected}} | ||||||
disabled={flattenedSections.allOptions.length === flattenedSections.disabledOptionsIndexes.length} | ||||||
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}} | ||||||
onMouseDown={shouldPreventDefaultFocusOnSelectRow ? (e) => e.preventDefault() : undefined} | ||||||
> | ||||||
<View style={[styles.peopleRow, styles.userSelectNone, styles.ph4, styles.pb3, listHeaderWrapperStyle]}> | ||||||
<Checkbox | ||||||
accessibilityLabel={translate('workspace.people.selectAll')} | ||||||
isChecked={flattenedSections.allSelected} | ||||||
onPress={selectAllRow} | ||||||
disabled={flattenedSections.allOptions.length === flattenedSections.disabledOptionsIndexes.length} | ||||||
accessibilityLabel={translate('workspace.people.selectAll')} | ||||||
/> | ||||||
{customListHeader ?? ( | ||||||
<View style={[styles.flex1]}> | ||||||
<Text style={[styles.textStrong, styles.ph3]}>{translate('workspace.people.selectAll')}</Text> | ||||||
</View> | ||||||
)} | ||||||
</PressableWithFeedback> | ||||||
</View> | ||||||
)} | ||||||
{!headerMessage && !canSelectMultiple && customListHeader} | ||||||
<SectionList | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAB:
use
useCallback
withitem
dependency.or I think
onPress={() => (onCheckboxPress ?? onSelectRow)(item)}
is better without defining this function