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

Replaced the Placeholder with 'Find' for smaller screen sizes #12997

Merged
merged 1 commit into from
Jan 15, 2025

Conversation

Abhishek-Punhani
Copy link
Contributor

The placeholder text is replaced with a shorter string "Find" when the viewport width is between 840 and 1264 pixels.
Fixes : #12238
Screenshot from 2025-01-13 19-13-03

Copy link
Member

@AlexVelezLl AlexVelezLl 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 your contribution @Abhishek-Punhani! Code changes makes sese to me, although we have this useKResponsiveWindow composable that can help better in this case :).

Also, just a little note: As flagged in #12238 (comment), we have two things to do here:

* In all cases, truncate "Find something to learn" with ellipsis ...
* Further improve experience by changing "Find something to learn" string to only "Find" on all smaller breakpoints where "Find something to learn" is not visible in its entirety (truncation described above serves rather as fallback to this behavior because we may not be able to estimate precisely)

We have met just the second point with this PR. Lets try to met the first point using some css :).

Let us know if you have any question.

@@ -117,15 +121,29 @@
textAlign: this.isRtl ? 'right' : '',
};
},
computedPlaceholder() {
if (this.viewportWidth < 1264 && this.viewportWidth >= 840) {
Copy link
Member

Choose a reason for hiding this comment

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

Here instead of checking with these specific pixels, lets instead do this check using our useKResponsiveWindow composable. We can use the windowBreakpoint property, and lets show the "find" string if this windowBreakpoint is 3 or 4 which are the corresponding breakpoints.

},
created() {
Copy link
Member

Choose a reason for hiding this comment

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

After using useKResponsiveWindow, we can remove these listeners and watchers since that composable already take care of that.

@@ -66,6 +66,9 @@
export default {
name: 'SearchBox',
mixins: [commonCoreStrings],
$trs: {
Copy link
Member

Choose a reason for hiding this comment

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

Lets add this property as the last property of the exported object. And lets run yarn lint-frontend:format to correct some linting errors in the PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AlexVelezLl
Thank you for the feedback and guidance!

I've made the requested changes:

  • Implemented the use of useKResponsiveWindow to determine breakpoints dynamically.
  • Added a CSS solution to truncate the placeholder text "Find something to learn" with an ellipsis (text-overflow: ellipsis, white-space: nowrap, and overflow: hidden styles applied to the .search-input element).
  • Updated the placeholder text to dynamically display "Find" on smaller screens (breakpoint <= 3.5) where truncation isn't sufficient.
  • Reduced the placeholder font size for better fit and readability on narrower viewports (font-size: 12px for screens below 1260px).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screencast.from.01-14-2025.11.45.39.AM.webm

@Abhishek-Punhani Abhishek-Punhani force-pushed the Issue#12238 branch 3 times, most recently from 1e95c8d to cebbfcf Compare January 14, 2025 06:14
Copy link
Member

@AlexVelezLl AlexVelezLl left a comment

Choose a reason for hiding this comment

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

Thanks @Abhishek-Punhani! We are almost there! I just left some minor comments, let me know if you have any question :).

@@ -117,6 +124,12 @@
textAlign: this.isRtl ? 'right' : '',
};
},
computedPlaceholder() {
if (this.windowBreakpoint <= 3.5) {
Copy link
Member

Choose a reason for hiding this comment

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

We should just test for 3 and 4 breakpoints, so lets update this validation to if ([3, 4].includes(this.windowBreakpoint)) {

vertical-align: middle;
border: 0;
@media (max-width: 1260px) {
&::placeholder {
font-size: 12px;
Copy link
Member

Choose a reason for hiding this comment

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

Lets remove this font-size, as is being too small, and the font-size of the rest of the text doesnt change, so I think the placeholder text shouldnt neither.

if (this.windowBreakpoint <= 3.5) {
return this.$tr('find');
}
return this.placeholder || coreString('searchLabel');
Copy link
Member

Choose a reason for hiding this comment

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

Bear in mind that the this.placeholder value should have max priority. If its defined we should return it regardless of the windowBreakpoint

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AlexVelezLl Thank you for the feedback!

Just to confirm, should we always display this.placeholder regardless of the screen size? And only when this.placeholder is not defined, we fallback to displaying "Find" for smaller screen sizes? Please let me know if that aligns with the expected behavior, and I can make the necessary adjustments.

Copy link
Member

Choose a reason for hiding this comment

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

Just to confirm, should we always display this.placeholder regardless of the screen size? And only when this.placeholder is not defined, we fallback to displaying "Find" for smaller screen sizes?

Yes, thats it @Abhishek-Punhani . We only need to tweak the find... string when there isnt a this.placeholder value set

Copy link
Contributor Author

@Abhishek-Punhani Abhishek-Punhani Jan 14, 2025

Choose a reason for hiding this comment

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

@AlexVelezLl Thanks for clarifying. I guess I have already pushed required changes .Please let me know if any further changes are required.

Copy link
Member

@AlexVelezLl AlexVelezLl 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 your contribution @Abhishek-Punhani! Code changes makes sense, and manual QA confirms the expected behaviour. Thanks!

@AlexVelezLl AlexVelezLl merged commit c9b1923 into learningequality:develop Jan 15, 2025
37 checks passed
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.

Keywords search placeholder text cut off at narrow sizes
2 participants