Skip to content

Commit

Permalink
fix(layoutSider): dimensionMap for max-width media query
Browse files Browse the repository at this point in the history
According to visibility problem (on viewport breakpoints) with Sider menu in our App
And according to Bootstrap responsive breakpoints https://getbootstrap.com/docs/4.0/layout/overview/#responsive-breakpoints

We should use different values for `min-width` and `max-width`. For example, if we construct query with `min-width: 768px` then we MUST use `max-width: 767.98px` for proper breakpoint determination otherwise they conflict with each other when have similar values.
  • Loading branch information
Nikitenkova authored Aug 29, 2019
1 parent c54bffb commit ff83e1a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions components/layout/Sider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ if (typeof window !== 'undefined') {
window.matchMedia = window.matchMedia || matchMediaPolyfill;
}

const dimensionMap = {
xs: '480px',
sm: '576px',
md: '768px',
lg: '992px',
xl: '1200px',
xxl: '1600px',
const dimensionMaxMap = {
xs: '479.98px',
sm: '575.98px',
md: '767.98px',
lg: '991.98px',
xl: '1199.98px',
xxl: '1599.98px',
};

export interface SiderContextProps {
Expand Down Expand Up @@ -105,8 +105,8 @@ class InternalSider extends React.Component<InternalSideProps, SiderState> {
if (typeof window !== 'undefined') {
matchMedia = window.matchMedia;
}
if (matchMedia && props.breakpoint && props.breakpoint in dimensionMap) {
this.mql = matchMedia(`(max-width: ${dimensionMap[props.breakpoint]})`);
if (matchMedia && props.breakpoint && props.breakpoint in dimensionMaxMap) {
this.mql = matchMedia(`(max-width: ${dimensionMaxMap[props.breakpoint]})`);
}
let collapsed;
if ('collapsed' in props) {
Expand Down

0 comments on commit ff83e1a

Please sign in to comment.