Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

feat(multiselect): auto-adjust height, width & position of multiple-select.js #59

Merged
merged 6 commits into from
Aug 29, 2018

Conversation

ghiscoding
Copy link
Owner

@ghiscoding ghiscoding commented Aug 28, 2018

  • add few new flags directly in multiple-select.js and remove previous code (that was not always working) new flags are:
    • autoAdjustDropHeight
    • autoAdjustDropPosition
    • autoAdjustDropWidthByTextSize
  • also in multiple-select.js you might want to use certain minimum or maximum height/width, so we also added the following options:
    • minWidth (defaults to null, to use when autoAdjustDropWidthByTextSize is enabled)
    • maxWidth (defaults to 500, to use when autoAdjustDropWidthByTextSize is enabled)
    • adjustHeightPadding (defaults to 10, to use when autoAdjustDropHeight is enabled)
    • maxHeight (defaults to 275, to use when autoAdjustDropHeight is enabled)
  • removed duplicate code in Select Filters & Editors to toggling drop position (top/bottom) and replace it all by simply these 3 new flags and set them all to true
  • fixed Select Editors having an extra offset to the left
  • selectEditor & selectFilter now use these new autoDropX all true by default, though user can choose at any to change them in their grids

Default Behaviors

  • autoAdjustDropWidthByTextSize will loop through every text from the collection and calculate it's maximum width.
    1. if new calculated width is smaller than the "Select All" text (this text can also be changed), it will instead use the width of the "Select All" text width.
    2. if new calculated width is bigger than maxWidth, it will instead use the maxWidth value.
    3. if new calculated width is smaller than minWidth, it will instead use the minWidth value.
    4. if the new calculate width is smaller than the select DOM element, it will use the select element width in this case
    5. finally if none of the previous validations (1-4) kicked in, we'll use the new calculated value
  • autoAdjustDropHeight is enabled and autoAdjustDropPosition is enabled
    1. if bottom area has enough space to show drop at the bottom, it will use bottom position, since it always prioritize the bottom area before the top.
    2. if bottom area is not big enough to contain the drop with the maxHeight, it will then choose which of the area has the most space (top or bottom)
    3. now that we know the position that will be used, we can calculate new drop height and resize it
  • autoAdjustDropHeight is enabled and autoAdjustDropPosition is disabled
    1. simply calculate available space from the actual position to use (bottom is default but there is an option to change it as well)

2018-08-28_23-48-48

Ghislain Beaulac added 6 commits August 27, 2018 20:09
- fixed select editor having wrong offset left
- add few new flags in multiple-select.js (autoDropHeight, autoDropPosition, autoDropWidth, autoDropWidthByTextSize, maxWidth, minWidth)
- selectEditor & selectFilter now use these new autoDropX all true by default, though user can choose at any to change them in their grids
- also renamed all flags with "adjust" ("autoDropHeight" to "autoAdjustDropHeight", ...)
- add "adjustHeightPadding" property
@ghiscoding ghiscoding changed the title feat(multiselect): auto-adjust height & position of multiple-select.js feat(multiselect): auto-adjust height, width & position of multiple-select.js Aug 29, 2018
@ghiscoding ghiscoding merged commit b5c83aa into master Aug 29, 2018
@ghiscoding ghiscoding deleted the feat/auto-adjust-multiple-select branch August 29, 2018 22:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant