Skip to content

Conversation

edanzer
Copy link
Contributor

@edanzer edanzer commented Sep 17, 2025

Proposed changes:

While testing another PR, I found the value bubble over the slider was mispositioned in the editor, but not the frontend. I think this occurred when we consolidated CSS for editor/frontend into a single file. We have two separate method for calculating slider position in editor/frontend, and I think one was updated and the other was not.

This PR creates a single utility method for calculating slider position, and imports and uses it in both editor and frontend. That fixes the original issue, but also the code duplication.

Before: Note value bubble is too far left at 0 and too far right at 100
slider-position-before-1
slider-position-before-2

After: Note value bubble is always centered over slider bullet
slider-value-position-after-1
slider value postition-after-2

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

Testing instructions:

  • Add a form to page and add a slider field
  • Move the slider control, and confirm the value bubble always stays centered above the slider bullet
  • Save and confirm the same thing for the slider on the frontend

@edanzer edanzer requested a review from a team September 17, 2025 16:36
@edanzer edanzer self-assigned this Sep 17, 2025
@edanzer edanzer added [Type] Bug When a feature is broken and / or not performing as intended [Status] Needs Review This PR is ready for review. [Pri] Normal [Block] Contact Form Form block (also see Contact Form label) [Package] Forms [Feature] Forms Blocks Blocks designed to streamline user input and engagement, such as contact, newsletter sign-ups, etc. labels Sep 17, 2025
Copy link
Contributor

github-actions bot commented Sep 17, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the fix/forms-slider-value-position branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/forms-slider-value-position

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions bot added [Feature] Contact Form [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ labels Sep 17, 2025
Copy link
Contributor

github-actions bot commented Sep 17, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: October 7, 2025
    • Code freeze: October 6, 2025

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

const percent = ( ( value - min ) * 100 ) / ( max - min );
// Magic numbers: 16px base offset, 0.32px per percent
return `calc(${ percent }% + (${ 16 - percent * 0.32 }px))`;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If there's a better place for shared JS utility methods to live, or if we would rather create a catchall util.js file and put methods in that, let me know.

Copy link
Member

Choose a reason for hiding this comment

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

Since the util is specific to the slider field (with magic numbers and all), might make sense to keep it in the slider field folder and share between front/back from there?

Copy link
Contributor Author

@edanzer edanzer Sep 17, 2025

Choose a reason for hiding this comment

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

Yes, we could do that. In terms of code organization, the code is used in in both blocks and module folders here:
forms/src/blocks/input-range/edit.js
forms/src/modules/field-slider/view.js

One thing I've been meaning to ask, is why we put view.js in a separate modules folder? I think traditionally in block development, a block's view.js (it's frontend JS) just lives in the block folder along with other block related code.

Any opposition to moving the view.js to the block folder (may have to update some config somewhere too)? Then frontend JS, editor JS, and any utils would all be consolidated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a separate discussion on slack now about view.js loading from block folder. For this PR, to keep things moving, I've just moved the shared method to a util.js folder in the input-range block folder. So it lives close to the block code, and then we just import it to view.js from there. Hopefully we'll eventually move view.js to the block folder too.

Since I already had approval on this PR and just move the method definition, once tests pass, I'll go ahead and merge.

Copy link

jp-launch-control bot commented Sep 17, 2025

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/packages/forms/src/modules/slider-field/view.js 0/14 (0.00%) 0.00% -3 💚
projects/packages/forms/src/blocks/input-range/edit.js 0/53 (0.00%) 0.00% -4 💚

1 file is newly checked for coverage.

File Coverage
projects/packages/forms/src/blocks/input-range/utils.js 0/7 (0.00%) 💔

Full summary · PHP report · JS report

If appropriate, add one of these labels to override the failing coverage check: Covered by non-unit tests Use to ignore the Code coverage requirement check when E2Es or other non-unit tests cover the code Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage.

enejb
enejb previously approved these changes Sep 17, 2025
Copy link
Member

@enejb enejb left a comment

Choose a reason for hiding this comment

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

This changed worked well for me!

@edanzer edanzer force-pushed the fix/forms-slider-value-position branch from ff5dae3 to 3b1e66e Compare September 18, 2025 14:51
@edanzer edanzer merged commit 498bcfe into trunk Sep 18, 2025
66 of 67 checks passed
@edanzer edanzer deleted the fix/forms-slider-value-position branch September 18, 2025 15:22
@github-actions github-actions bot removed the [Status] Needs Review This PR is ready for review. label Sep 18, 2025
@github-actions github-actions bot added this to the jetpack/15.1 milestone Sep 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Contact Form Form block (also see Contact Form label) [Feature] Contact Form [Feature] Forms Blocks Blocks designed to streamline user input and engagement, such as contact, newsletter sign-ups, etc. [Package] Forms [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Pri] Normal [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants