swordev / suid

A port of Material-UI (MUI) built with SolidJS.
https://suid.io
MIT License
660 stars 47 forks source link

SSR Support for Select component #268

Open BierDav opened 9 months ago

BierDav commented 9 months ago

Hello, I'm a student and we really need ssr support for this specific component in our project. I tried to do it my self but failed due to the harsh complexity, but @juanrgm as an experienced solid js developer should be able to pull this off. To get this fixed, I even sponsored πŸ™‚

Just a quick overview of challenges I faced while trying to implementing this:

I would really appreciate any help, feedback or advice πŸ’–

BierDav commented 8 months ago

Hello guys! There is an update on this topic from my side. I have been working on a version of that component on my own to support SSR and dynamic ranges. You can check it out here πŸ€“ Unfortunately, it currently doesn't support autofocus. I don't think it is a big technical issue, but the first attempt I gave it didn't work and I don't have enough time to fix that, because for us it is good enough. Also, the API is a bit different to MUI, but feels quite similar other than solid-select which might seam quite limiting. πŸ˜‰

Have a nice day! πŸ‘‹ BierDav

YannickFuereder commented 7 months ago

Another option would be to just import the Select Component on the client side only

Example:

import { Box, FormControl, InputLabel, MenuItem } from "@suid/material";
import { createSignal } from "solid-js";
import { clientOnly } from 'solid-start/islands';

const Select = clientOnly(() => import('@suid/material/Select'));

export default function StateSelect() {
  const [age, setAge] = createSignal("");

  const handleChange = (event) => {
    setAge(event.target.value);
  };

  return (
    <Box sx={{ minWidth: 120 }}>
      <FormControl fullWidth>
        <InputLabel id="demo-simple-select-label">Age</InputLabel>
        <Select
          labelId="demo-simple-select-label"
          id="demo-simple-select"
          value={age()}
          label="Age"
          onChange={handleChange}
        >
          <MenuItem value={10}>Ten</MenuItem>
          <MenuItem value={20}>Twenty</MenuItem>
          <MenuItem value={30}>Thirty</MenuItem>
        </Select>
      </FormControl>
    </Box>
  );
}
BierDav commented 7 months ago

Yeah, but with that we don't support ssr and instead disable it