clarify behavior of Picker placeholder inside a native <form> #1626
              
                
                  
                  
                    Answered
                  
                  by
                    LFDanLu
                  
              
          
                  
                    
                      stefanprobst
                    
                  
                
                  asked this question in
                Q&A
              
            -
| placing a  both  import {
  Provider,
  defaultTheme,
  Picker,
  Item,
  Button,
} from "@adobe/react-spectrum";
export default function App() {
  function onSubmit(e) {
    e.preventDefault();
    const formData = new FormData(e.currentTarget);
    alert(JSON.stringify(Object.fromEntries(formData), null, 2));
  }
  return (
    <Provider theme={defaultTheme} locale="en">
      <main>
        <form onSubmit={onSubmit}>
          <Picker label="Color" name="color">
            <Item key="blue">Blue</Item>
            <Item key="red">Red</Item>
            <Item key="green">Green</Item>
          </Picker>
          <div>
            <Button type="submit">Submit</Button>
          </div>
        </form>
        <hr />
        <form onSubmit={onSubmit}>
          <label>
            <span>Color</span>
            <select name="color">
              <option value="blue">Blue</option>
              <option value="red">Red</option>
              <option value="green">Green</option>
            </select>
          </label>
          <div>
            <button type="submit">Submit</button>
          </div>
        </form>
      </main>
    </Provider>
  );
} | 
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            LFDanLu
          
      
      
        Feb 24, 2021 
      
    
    Replies: 1 comment 2 replies
-
| I wonder if this is due to the HiddenSelect that Picker uses, perhaps it should have a "no option selected" item as its default. Will need to dig | 
Beta Was this translation helpful? Give feedback.
                  
                    2 replies
                  
                
            
      Answer selected by
        devongovett
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
I wonder if this is due to the HiddenSelect that Picker uses, perhaps it should have a "no option selected" item as its default. Will need to dig