Skip to content
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

fix: TimeZone dropdown clips through screen in Mobile viewport #7935

Merged
merged 8 commits into from
Oct 28, 2024

Conversation

harshit078
Copy link
Contributor

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR addresses the timezone dropdown clipping and transparency issues in mobile viewports by introducing responsive width adjustments to the Dropdown and DropdownMenu components.

  • Added 'mobileDropdownWidth' prop to Dropdown.tsx for viewport-specific width control
  • Implemented MOBILE_VIEWPORT constant in DropdownMenu.tsx to determine appropriate width
  • Modified DropdownMenu styling to reduce transparency and improve visibility
  • Adjusted dropdown width calculation in Dropdown.tsx to consider mobile viewport
  • Ensured full-width rendering for desktop filters dropdown as per issue requirements

2 file(s) reviewed, 6 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines 73 to 76
const dropdownWidth =
mobileDropdownWidth && window.innerWidth <= MOBILE_VIEWPORT
? mobileDropdownWidth
: dropdownMenuWidth;
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: This logic might cause issues if window is undefined in SSR environments

useDropdown(dropdownId);

const offsetMiddlewares = [];
const dropdownWidth =
mobileDropdownWidth && window.innerWidth <= MOBILE_VIEWPORT
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider using a hook like useMediaQuery for responsive behavior instead of directly checking window.innerWidth

@@ -1,9 +1,10 @@
import styled from '@emotion/styled';

import { MOBILE_VIEWPORT } from 'twenty-ui';
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider using a more specific import for MOBILE_VIEWPORT

width: ${({ width = 160 }) =>
typeof width === 'number' ? `${width}px` : width};
width: ${({ width = 160, mobileDropdownWidth }) => {
const isMobileViewport = MOBILE_VIEWPORT;
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: MOBILE_VIEWPORT is likely a boolean, not a function. Remove unnecessary const assignment

typeof width === 'number' ? `${width}px` : width};
width: ${({ width = 160, mobileDropdownWidth }) => {
const isMobileViewport = MOBILE_VIEWPORT;
if (Boolean(isMobileViewport) && Boolean(mobileDropdownWidth)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Unnecessary Boolean() wrapping, MOBILE_VIEWPORT is already a boolean

Comment on lines 29 to 37
width: ${({ width = 160, mobileDropdownWidth }) => {
const isMobileViewport = MOBILE_VIEWPORT;
if (Boolean(isMobileViewport) && Boolean(mobileDropdownWidth)) {
return typeof mobileDropdownWidth === 'number'
? `${mobileDropdownWidth}px`
: mobileDropdownWidth;
}
return typeof width === 'number' ? `${width}px` : width;
}};
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider extracting this logic into a separate function for better readability

@martmull
Copy link
Contributor

image
It looks that drowdown width matching Select component does not work for all mobile screen widths. Am i wrong with smtg?

@martmull
Copy link
Contributor

Fixed with new property
image

@martmull martmull enabled auto-merge (squash) October 28, 2024 16:06
@martmull martmull merged commit cabae4c into twentyhq:main Oct 28, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants