Skip to content

Picker selection control bar and toggle all items functionality #3557

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

Merged
merged 34 commits into from
Mar 24, 2025

Conversation

adids1221
Copy link
Contributor

@adids1221 adids1221 commented Mar 6, 2025

Description

Picker new selectionStatus feature, let the user use 2 types of "Select All" elements - Button, CheckBox.
All the draft state management are inside the new PickerSelectionControlBar component.

This is a new feature that meant to replace renderCustomTopElement logic (#3465).

Snapshot version for testing: 7.39.0-snapshot. 6618

Changelog

Picker new selectionStatus feature, support "Select All" element.

Additional info

None

@adids1221
Copy link
Contributor Author

adids1221 commented Mar 6, 2025

@M-i-k-e-l let's sync about the getLabel type I need to "accurate" the use of this prop.

@adids1221
Copy link
Contributor Author

TODO: Check on Private

@M-i-k-e-l M-i-k-e-l assigned adids1221 and unassigned M-i-k-e-l Mar 16, 2025
@adids1221
Copy link
Contributor Author

@M-i-k-e-l I removed the none type, I think it's unnecessary at the moment.

@adids1221 adids1221 requested a review from M-i-k-e-l March 17, 2025 10:23
@adids1221 adids1221 assigned M-i-k-e-l and unassigned adids1221 Mar 17, 2025
@M-i-k-e-l M-i-k-e-l assigned adids1221 and unassigned M-i-k-e-l Mar 18, 2025
@adids1221 adids1221 removed their assignment Mar 20, 2025
@adids1221
Copy link
Contributor Author

@M-i-k-e-l the renderSelectionStatus refactor is for satiation when the user pass showLabel: false and the selection component should align to the right.

@M-i-k-e-l M-i-k-e-l assigned adids1221 and unassigned M-i-k-e-l Mar 23, 2025
@adids1221 adids1221 requested a review from M-i-k-e-l March 23, 2025 18:28
@adids1221 adids1221 assigned M-i-k-e-l and unassigned adids1221 Mar 23, 2025
@M-i-k-e-l M-i-k-e-l assigned adids1221 and unassigned M-i-k-e-l Mar 24, 2025
@adids1221 adids1221 assigned M-i-k-e-l and unassigned adids1221 Mar 24, 2025

export default function PickerSelectionStatusBar(props: PickerSelectionStatusProps) {
const {containerStyle, getLabel, showLabel = true} = props;
const context = useContext(PickerContext);
const {toggleAllItemsSelection, value = [], areAllItemsSelected} = context;
const _value: PickerMultiValue = value as PickerMultiValue;
const {toggleAllItemsSelection, selectedCount = 0, areAllItemsSelected} = context;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there should be a default value here


const checkboxIndeterminate = _value.length > 0 && !areAllItemsSelected;
const checkboxIndeterminate = !!selectedCount && !areAllItemsSelected;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think selectedCount > 0 is more readable

@M-i-k-e-l M-i-k-e-l assigned adids1221 and unassigned M-i-k-e-l Mar 24, 2025
@adids1221 adids1221 assigned M-i-k-e-l and unassigned adids1221 Mar 24, 2025
@M-i-k-e-l M-i-k-e-l enabled auto-merge (squash) March 24, 2025 08:50
@M-i-k-e-l M-i-k-e-l merged commit 07b9a10 into master Mar 24, 2025
1 check passed
@M-i-k-e-l M-i-k-e-l deleted the feat/Picker_selection_control_bar branch March 24, 2025 08:51
adids1221 added a commit that referenced this pull request Mar 31, 2025
* Picker selection control bar and toggle all items functionality

* Refactor PickerScreen layout

* Rename PickerSelectionControlBar to PickerSelectionStatusToolbar and update related references

* Enhance selection status label functionality in PickerSelectionStatusToolbar

* Refactor PickerSelectionStatusToolbar and types for improved selection handling

* Remove 'none' option from select all types in Picker and update related types

* Fix types issue in PickerItemsList

* Refactor toggleAllItemsSelection and availableItems usage

* Remove customLabel prop from PickerSelectionStatusProps

* Add renderTopCustomElement and renderBottomCustomElement props to PickerSelectionStatusToolbar

* Rename getLabel prop to getSelectionStatusLabe and update related usages

* Refactor selectionStatus handling in PickerItemsList

* Remove unnecessary null return in renderLabel

* Remove renderTopCustomElement prop

* Rename _onSegmentChange to onSegmentChange

* Fix TypeScript ignore directive for selectAllType in Picker

* Update buttonProps onPress parameter to use selectionValue and set default selectAllType to 'button'

* Refactor Picker selection logic to use areAllItemsSelected and simplify selection status handling

* Rename getSelectionStatusLabel to getLabel and update type definitions for clarity

* Remove renderBottomCustomElement prop and add divider in PickerSelectionStatusToolbar

* Refactor Picker component to remove PickerSelectAllType enum

* Refactor PickerSelectionStatusToolbar to simplify props and selection handling

* Rename PickerSelectionStatusToolbar to PickerSelectionStatusBar and update related references

* Update buttonProps onPress to use customValue instead of selectionValue in PickerSelectionStatusBar

* Add selectAllType prop to PickerSelectionStatusBar for flexible selection handling

* Refactor PickerSelectionStatusBar to remove selectAllType prop and simplify selection handling

* Fix type assertion for value in PickerSelectionStatusBar to ensure correct handling of PickerMultiValue

* Refactor renderSelectionStatus, fix when showLabel is false

* Add PickerSelectionStatusProps import to PickerScreen and index files

* Remove unused setMultiFinalValue from usePickerSelection hook

* Remove value from PickerSelectionStatusLabelData

* selectedCount moved to usePickerSelection

* PickerSelectionStatusBar simplify selectedCount

---------

Co-authored-by: Miki Leib <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants