Skip to content

Commit

Permalink
Merge pull request #1808 from epam/fix/picker-input-body-responsiveness
Browse files Browse the repository at this point in the history
[PickerInput]: Fixed picker input body responsiveness.
  • Loading branch information
AlekseyManetov authored Dec 6, 2023
2 parents ea91500 + 90aafd0 commit 035cc1b
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 14 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
**What's Fixed**
* [Button]: fixed `rawProps` typings for `data-*` attributes
* [Paginator]: fixed `rawProps` typings
* [PickerInput]: Fixed picker input body responsiveness.
* `DropdownContainer` `width` property affects `maxWidth` if `maxWidth` is not provided.
* [PickerInput]: Fixed clear checked before opening a picker body and if selectAll: false is provided.
* Added `clearAllChecked()` method to `IDataSourceView` interface to support unchecking all without enabled `selectAll` flag.
* Reduced amount of loaded data while clearing all checked elements in `cascadeSelection: false` mode.
Expand Down
6 changes: 3 additions & 3 deletions uui-components/src/overlays/DropdownContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export interface DropdownContainerProps
IDropdownBodyProps {
/** Defines width in 'px' or 'auto'. If 'auto' provided, will be used width of the content. */
width?: number | 'auto';
/** Defines maximum width in 'px'. */
maxWidth?: number;
/** Defines maximum width in 'px'. If 'auto' provided, will be used width of the content. */
maxWidth?: number | 'auto';
/** Defines height in 'px'. */
height?: number;
/** If true, arrow tip will be shown
Expand Down Expand Up @@ -79,7 +79,7 @@ export const DropdownContainer = React.forwardRef((props: DropdownContainerProps
forwardedRef={ !focusLock && ref as React.ForwardedRef<HTMLDivElement> }
cx={ cx(uuiElement.dropdownBody, uuiMarkers.lockFocus, props.cx) }
style={ {
...props.style, minWidth: props.width, minHeight: props.height, maxWidth: props.maxWidth,
...props.style, minWidth: props.width, minHeight: props.height, maxWidth: props.maxWidth ?? props.width,
} }
rawProps={ { tabIndex: -1, ...props.rawProps } }
>
Expand Down
2 changes: 2 additions & 0 deletions uui/components/filters/FilterPickerBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export function FilterPickerBody<TItem, TId>(props: FilterPickerBodyProps<TItem,
const renderBody = (bodyProps: DataSourceListProps & Omit<PickerBodyBaseProps, 'rows'>, rows: DataRowProps<TItem, TId>[]) => {
const renderedDataRows = rows.map((props) => renderRow(props));
const maxHeight = isMobile() ? document.documentElement.clientHeight : props.dropdownHeight || pickerHeight;
const maxWidth = isMobile() ? undefined : 360;

return (
<>
Expand All @@ -59,6 +60,7 @@ export function FilterPickerBody<TItem, TId>(props: FilterPickerBodyProps<TItem,
selectionMode={ props.selectionMode }
rows={ renderedDataRows }
maxHeight={ maxHeight }
maxWidth={ maxWidth }
searchSize="36"
editMode="dropdown"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ exports[`DropdownContainer should be rendered correctly 2`] = `
className="uui-dropdown-body -lock-focus root vPadding-18 padding-24 container"
style={
Object {
"maxWidth": undefined,
"maxWidth": 300,
"minHeight": 600,
"minWidth": 300,
}
Expand Down
3 changes: 2 additions & 1 deletion uui/components/pickers/DataPickerBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface DataPickerBodyProps extends PickerBodyBaseProps {
editMode?: 'dropdown' | 'modal';
searchSize?: ControlSize;
selectionMode?: 'single' | 'multi';
maxWidth?: number;
}

export class DataPickerBody extends PickerBodyBase<DataPickerBodyProps> {
Expand Down Expand Up @@ -51,7 +52,7 @@ export class DataPickerBody extends PickerBodyBase<DataPickerBodyProps> {
</FlexCell>
</div>
)}
<FlexRow key="body" cx={ cx(css.body, css[this.props.editMode], css[this.props.selectionMode]) } rawProps={ { style: { maxHeight: this.props.maxHeight } } }>
<FlexRow key="body" cx={ cx(css.body, css[this.props.editMode], css[this.props.selectionMode]) } rawProps={ { style: { maxHeight: this.props.maxHeight, maxWidth: this.props.maxWidth } } }>
{ this.props.rowsCount > 0 ? (
<VirtualList
{ ...this.lens.toProps() }
Expand Down
9 changes: 4 additions & 5 deletions uui/components/pickers/MobileDropdownWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,19 @@ interface IMobileDropdownWrapperProps extends IHasCX, IHasRawProps<React.HTMLAtt
title?: string;
onKeyDown?(e: React.KeyboardEvent<HTMLElement>): void;
focusLock?: boolean;
width?: number;
width?: number | 'auto';
maxWidth?: number | 'auto';
}

export const MobileDropdownWrapper: React.FC<IMobileDropdownWrapperProps> = (props) => {
const isMobileView = isMobile();
const maxWidth = isMobileView ? 'auto' : props.maxWidth;

return (
<DropdownContainer
{ ...props }
maxWidth={ maxWidth }
cx={ [css.container, props.cx] }
rawProps={ props.rawProps }
onKeyDown={ props.onKeyDown }
focusLock={ props.focusLock }
width={ props.width }
>
{isMobileView && <DataPickerHeader title={ props.title } close={ props.onClose } />}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Array [
Object {
"columnGap": undefined,
"maxHeight": 800,
"maxWidth": undefined,
"rowGap": undefined,
}
}
Expand Down Expand Up @@ -154,6 +155,7 @@ exports[`DataPickerBody should be rendered with minimum props 1`] = `
Object {
"columnGap": undefined,
"maxHeight": undefined,
"maxWidth": undefined,
"rowGap": undefined,
}
}
Expand Down Expand Up @@ -187,6 +189,7 @@ exports[`DataPickerBody should be rendered without rows 1`] = `
Object {
"columnGap": undefined,
"maxHeight": undefined,
"maxWidth": undefined,
"rowGap": undefined,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ exports[`PickerInput should open body 1`] = `
>
<div
class="uui-dropdown-body -lock-focus root container container"
style="min-width: 360px;"
style="min-width: 360px; max-width: 360px;"
tabindex="-1"
>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ exports[`PickerModal should be rendered correctly 1`] = `
Object {
"columnGap": undefined,
"maxHeight": undefined,
"maxWidth": undefined,
"rowGap": undefined,
}
}
Expand Down Expand Up @@ -524,6 +525,7 @@ exports[`PickerModal should be rendered correctly with maximum props 1`] = `
Object {
"columnGap": undefined,
"maxHeight": undefined,
"maxWidth": undefined,
"rowGap": undefined,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const ColumnHeaderDropdownImpl: React.FC<ColumnHeaderDropdownProps> = (props) =>
<Dropdown
renderTarget={ props.renderTarget }
renderBody={ (dropdownProps) => (
<MobileDropdownWrapper width={ 280 } title={ props.title } onClose={ closeDropdown }>
<MobileDropdownWrapper width={ 360 } maxWidth="auto" title={ props.title } onClose={ closeDropdown }>
{props.isSortable && <SortingPanel sortDirection={ props.sortDirection } onSort={ props.onSort } />}
{props.renderFilter(dropdownProps)}
</MobileDropdownWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ Array [
className="uui-dropdown-body -lock-focus root container container"
style={
Object {
"maxWidth": undefined,
"maxWidth": "auto",
"minHeight": undefined,
"minWidth": 280,
"minWidth": 360,
}
}
tabIndex={-1}
Expand Down

0 comments on commit 035cc1b

Please sign in to comment.