Skip to content

[slider][field] Integrate range sliders with field #1929

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mj12albert
Copy link
Member

@mj12albert mj12albert commented May 15, 2025

Part of #1864

Preview: https://deploy-preview-1929--base-ui.netlify.app/experiments/slider/form

Added a <input type="hidden"> in the root that is wired to Field and Form instead of the thumb's <input type="range">

One limitation is that if the range slider's value goes through FormData as part of form submission, it'll become a string ('[2,4]') and will need to be manually JSON.parse-ed

Copy link

pkg-pr-new bot commented May 15, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@base-ui-components/react@1929

commit: fbc72e5

Copy link

netlify bot commented May 15, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit fbc72e5
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/68270b51e536920008ba950f
😎 Deploy Preview https://deploy-preview-1929--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@mj12albert mj12albert force-pushed the slider/range-slider-field branch from 7e754fc to 65c6ec7 Compare May 15, 2025 17:15
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 16, 2025
@mj12albert mj12albert force-pushed the slider/range-slider-field branch from cecf7a6 to c5f2040 Compare May 16, 2025 03:39
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label May 16, 2025
@mj12albert mj12albert force-pushed the slider/range-slider-field branch 4 times, most recently from 264eb89 to 75227c6 Compare May 16, 2025 09:19
@mj12albert mj12albert marked this pull request as ready for review May 16, 2025 09:23
@mj12albert mj12albert force-pushed the slider/range-slider-field branch from 75227c6 to 655e299 Compare May 16, 2025 09:44
@mj12albert mj12albert force-pushed the slider/range-slider-field branch from 655e299 to fbc72e5 Compare May 16, 2025 09:54
@atomiks
Copy link
Contributor

atomiks commented May 18, 2025

One limitation is that if the range slider's value goes through FormData as part of form submission, it'll become a string ('[2,4]') and will need to be manually JSON.parse-ed

I added multiple hidden inputs for the multi-select feature

{multiple &&
  Array.isArray(value) &&
    value.map((v) => <input key={v} type="hidden" name={name} value={v} />)}
const data = new FormData(event.currentTarget);
const submitted = data.getAll(name); // normal array

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.

2 participants