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

Tweak SnippetPreview #21469

Open
wants to merge 9 commits into
base: feature/plugin-fixes
Choose a base branch
from

Conversation

igorschoester
Copy link
Member

@igorschoester igorschoester commented Jul 9, 2024

Context

Summary

This PR can be summarized in the following changelog entry:

  • [@yoast/search-metadata-previews 0.1.0] Reads the user agent and shows a different desktop fixed width copy for mobile agents.
  • [@yoast/search-metadata-previews 0.1.0] Adds an extra container to the SnippetPreview' FixedWidthContainer, allowing for better outside styling control.
  • [@yoast/search-metadata-previews 0.1.0] Changes the FixedWidthContainer to show the scroll hint when a scrollbar is shown instead of whether the width prop is larger than the current width.
  • [@yoast/search-metadata-previews 0.0.1 non-user-facing] Adds a yarn watch command for ease of development.

Relevant technical choices:

Test instructions

Test instructions for the acceptance test before the PR gets merged

This PR can be acceptance tested by following these steps:

New copy

  • Edit a post on a mobile device, or in Chrome you can simulate using the device-mode
  • Go to the search appearance preview
  • Switch to the desktop result
  • Verify the copy is Drag to view the full preview.
  • Go back to a non-mobile device
  • Verify the copy is Scroll to see the preview content.

Regression tests

  • Edit a post
  • Check the search appearance preview
  • Verify there is no visible difference using the mobile result
  • Verify there is almost no visible difference using the desktop result, except:
    • When on a smaller screen than the content, you get a scroll hint
    • The spacing around the scroll hint is adapted to be 16px on the top and 8px on the bottom (though looking equal due to other factors)
    • Change the width of the screen and verify the scroll hint comes into play at exactly the right times (when the scrollbar is active)
  • You could check the same in the social previews

DEV only: yarn watch

  • Do a normal build first for the dependencies installation (PHP and JS)
  • Run yarn workspace @yoast/search-metadata-previews watch, or run yarn watch in the packages/search-metadata-previews folder
  • Make a change in the code of packages/search-metadata-previews
  • Verify the watcher picked it up (output + check/search in the build folder?)
  • If you would build Free (or run yarn start in the root), you would see the change on refresh of the page

Relevant test scenarios

  • Changes should be tested with the browser console open
  • Changes should be tested on different posts/pages/taxonomies/custom post types/custom taxonomies
  • Changes should be tested on different editors (Default Block/Gutenberg/Classic/Elementor/other)
  • Changes should be tested on different browsers
  • Changes should be tested on multisite

Test instructions for QA when the code is in the RC

  • QA should use the same steps as above.

QA can test this PR by following these steps:

Impact check

This PR affects the following parts of the plugin, which may require extra testing:

  • The UI of the search appearance preview.

UI changes

  • This PR changes the UI in the plugin. I have added the 'UI change' label to this PR.

Other environments

  • This PR also affects Shopify. I have added a changelog entry starting with [shopify-seo], added test instructions for Shopify and attached the Shopify label to this PR.

Documentation

  • I have written documentation for this change. For example, comments in the Relevant technical choices, comments in the code, documentation on Confluence / shared Google Drive / Yoast developer portal, or other.

Quality assurance

  • I have tested this code to the best of my abilities.
  • During testing, I had activated all plugins that Yoast SEO provides integrations for.
  • I have added unit tests to verify the code works as intended.
  • If any part of the code is behind a feature flag, my test instructions also cover cases where the feature flag is switched off.
  • I have written this PR in accordance with my team's definition of done.
  • I have checked that the base branch is correctly set.

Innovation

  • No innovation project is applicable for this PR.
  • This PR falls under an innovation project. I have attached the innovation label.
  • I have added my hours to the WBSO document.

Fixes https://github.com/Yoast/ux/issues/140

Reasoning: mobile users drag instead of scroll
Needed to be able to influence the fixed width background color
* using the given className extended with `__wrapper`
* add fallback for the className: fallback to the ID
* add className (same as the ID) to the FixedWidthContainer used in the SnippetPreview
For ease of development
@igorschoester igorschoester added changelog: enhancement Needs to be included in the 'Enhancements' category in the changelog Shopify This PR impacts Shopify. labels Jul 9, 2024
@igorschoester igorschoester marked this pull request as ready for review July 11, 2024 12:14
Making it possible to change the padding via CSS by checking the offsetWidth and comparing it against the scrollWidth.
This assumes the max-width and overflow remain in effect!
@@ -111,12 +111,13 @@ export default class FixedWidthContainer extends Component {
render() {
const { width, padding, children, className, id } = this.props;

const klass = className || id;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const klass = className || id;
const classNameOrId = className || id;

const innerWidth = width - 2 * padding;

return <React.Fragment>
return <div className={ `${ klass }__wrapper` }>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return <div className={ `${ klass }__wrapper` }>
return <div className={ `${ classNameOrId }__wrapper` }>

<FixedWidth
id={ id }
className={ className }
className={ klass }
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
className={ klass }
className={ classNameOrId }

this.setState( {
showScrollHint: width < this.props.width,
showScrollHint: this._container?.offsetWidth !== this._container?.scrollWidth,
isMobileUserAgent: window?.navigator?.userAgent?.includes( "Mobi" ),
Copy link
Member

Choose a reason for hiding this comment

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

What about a case insensitive check?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: enhancement Needs to be included in the 'Enhancements' category in the changelog Shopify This PR impacts Shopify.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants