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 searchbar overflowing for mobile #2009

Merged
merged 5 commits into from
Aug 17, 2022

Conversation

domlimm
Copy link
Contributor

@domlimm domlimm commented Aug 13, 2022

What is the purpose of this pull request?

  • Documentation update
  • Bug fix
  • Feature addition or enhancement
  • Code maintenance
  • DevOps
  • Improve developer experience
  • Others, please explain:

Overview of changes:
Fixes #2002.

Added a media query to handle for mobile screens (not too familiar but max-width: 768px seems to suffice).

In the media query, we set the min-width and max-width to follow the styling of the current prod's search bar.

Also, with reference to PR #1959 to not interfere with the implementation of it, and follow it by giving the search bar a min-width and max-width.

Anything you'd like to highlight/discuss:
NIL

Testing instructions:
Served locally.

Proposed commit message: (wrap lines at 72 characters)
Fix searchbar overflow for mobile screens


Checklist: ☑️

  • Updated the documentation for feature additions and enhancements
  • Added tests for bug fixes or features
  • Linked all related issues
  • No unrelated changes

Copy link
Contributor

@jonahtanjz jonahtanjz left a comment

Choose a reason for hiding this comment

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

Thanks @domlimm 👍

You may also want to add a media query for tablets (>767px and <879px). Currently the search bar is still overflowing for longer placeholders for the above range.

image

.form-control {
min-width: 8em;
max-width: 16em; /* twice of min-width, to accommodate a range of lengths */
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Some styling issue here causing the linting to fail. You may want to run npm run lintfix to help lint the code next time :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's right! Got to make running npm run lint a habit. Didn't realise the styles are using 4 spaces instead of 2. Thanks for the advice!!

@domlimm
Copy link
Contributor Author

domlimm commented Aug 13, 2022

Hey @jonahtanjz! Thanks for reviewing! And yes, slipped my mind to test for tablets 😅 Will add it in now! 👍🏻

@domlimm
Copy link
Contributor Author

domlimm commented Aug 13, 2022

@jonahtanjz Hey Jonah! Sorry that took awhile, was trying out what works best. FYI, if it's still overflowing when you are testing, you could refresh the page and it should work accordingly.

Thank you, appreciate it! 😄

Copy link
Contributor

@jonahtanjz jonahtanjz left a comment

Choose a reason for hiding this comment

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

Thanks for making the changes @domlimm!

LGTM 👍

@jonahtanjz jonahtanjz added this to the 4.0.1 milestone Aug 13, 2022
Copy link
Contributor

@tlylt tlylt left a comment

Choose a reason for hiding this comment

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

Not sure if I am missing anything, it seems to overflow after 767px:
image

@domlimm
Copy link
Contributor Author

domlimm commented Aug 14, 2022

@tlylt Yes, same behaviour at my end. Attached a demo below. By the way, the page flashes when it reloaded with F5.

Maybe might have to tweak the range.

demo.mp4

From w3schools:

/* Extra small devices (phones, 600px and down) */
@media only screen and (max-width: 600px) {...}

/* Small devices (portrait tablets and large phones, 600px and up) */
@media only screen and (min-width: 600px) {...}

/* Medium devices (landscape tablets, 768px and up) */
@media only screen and (min-width: 768px) {...}

/* Large devices (laptops/desktops, 992px and up) */
@media only screen and (min-width: 992px) {...}

/* Extra large devices (large laptops and desktops, 1200px and up) */
@media only screen and (min-width: 1200px) {...}

@jonahtanjz
Copy link
Contributor

jonahtanjz commented Aug 14, 2022

@tlylt @domlimm

I think this has more to do with the issue #1699. The width of the search bar will have to vary depending on the number of items in the navbar menu. There are a couple of solutions discussed here #1760 (review) if you are interested. This can be done in another PR :)

@domlimm domlimm force-pushed the fix-searchbar-overflow-mobile branch from 008afe9 to a39a92d Compare August 15, 2022 14:24
}

/* For general tablets in portrait e.g. iPad */
@media screen and (min-width: 768px) and (max-width: 878px) and (orientation: portrait) {
Copy link
Contributor

Choose a reason for hiding this comment

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

How about combining this with the above query since they have the same property?

@media screen and (max-width: 767px), screen and (min-width: 768px) and (max-width: 878px) and (orientation: portrait) {
        .form-control {
            min-width: 8em;
            max-width: 16em; /* twice of min-width, to accommodate a range of lengths */
        }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Jonah! Will make the change.

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.

Search bar overflows on mobile devices
3 participants