On Fri, Oct 24, 2008 at 12:37 AM, Andy Lyttle <span dir="ltr">&lt;<a href="mailto:whatwg@phroggy.com">whatwg@phroggy.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style=""><div class="Ih2E3d">
<div>On Oct 23, 2008, at 12:19 PM, Tab Atkins Jr. wrote:</div><blockquote type="cite"><div class="gmail_quote"><div>Ultimately the display of the hint is, and should be, up to the UA, so that non-full-featured devices can display things in a maximally helpful way to the user.&nbsp; Within the context of a standard browser on an ordinary computer, though, the correct display seems relatively clear.&nbsp; When the select is collapsed, the hint should show until the user selects something.&nbsp; After the user selects something, the hint will never again display in the collapsed state.&nbsp; I&#39;m not sure if it&#39;s necessary for the hint to display in the expanded state.&nbsp; If it is, though, then it should always be the first item in the list, and it should be nonselectable, similar to how column groups display currently.</div>
</div></blockquote></div></div></blockquote><div>My responses to the following questions (from Andy Lyttle, in case the quoting throws anyone) should be considered only my own opinions. <br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style=""><div>1) If the user clicks to open the menu, then clicks away or presses Esc without making a selection, does that count as a selection for purposes of making the placeholder not appear again?</div></div></blockquote>
<div><br>No.&nbsp; They have not yet selected anything.&nbsp; The situation is similar to the preferred display of the hint in a text input - if the user focusses the field (making the hint disappear) then changes the focus without ever entering anything, the hint should display again.<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div style=""><div></div><div>2) If the user never selects something, they&#39;ll never see anything but the placeholder. &nbsp;That means they won&#39;t see the text associated with whatever option is selected by default. &nbsp;In many cases, the default option will be some sort of blank* value to indicate that the user has not made a selection; the current practice serves both purposes at the same time (having a blank value to indicate no selection, and setting the text of that option to a placeholder/hint). &nbsp;A placeholder option would replace one of these purposes, but not both; authors would still need to have a default option that indicates non-selection.</div>
<div><br></div><div><div>* By blank, I mean something unique that the script that will process the form knows means a non-selection. &nbsp;I normally use &lt;option value=&quot;&quot;&gt; for this purpose, but it could be any value the author devises.</div>
<div><br></div></div><div>In other cases, there must always be something selected; a non-selection shouldn&#39;t be possible. &nbsp;An example might be the &quot;country&quot; field on an address form, which defaults to the most likely choice (e.g. United States for sites that expect most of their audience to be American). &nbsp;The user shouldn&#39;t be permitted to select a non-value. &nbsp;How should the placeholder text be displayed? &nbsp;It seems clear to me that it should NOT appear on the collapsed menu at all, but should appear at the top of the expanded menu.</div>
<div><br></div><div>There are other cases where having a blank option is appropriate, but the default may be something else. &nbsp;The user can explicitly change the selection to a blank option.</div><div><br></div><div>How should the placeholder behave in each of these cases?</div>
</div></blockquote><div><br>Very, very good questions.&nbsp; Okay, so let&#39;s go back to the beginning.&nbsp; &lt;select&gt; already has a widely-used hinting method.&nbsp; If there is an appropriate default &lt;option&gt;, then an author puts @selected on it, and everything&#39;s golden.&nbsp; If not, the author makes the very first &lt;option&gt; have an appropriately hint-y text, and an appropriate default value, so that they can distinguish on the server side that the &lt;select&gt; wasn&#39;t successfully submitted.&nbsp; These two methods are already widely used, so is there actually a problem needing to be solved here?&nbsp; Both methods will also need to be supported into the future as fallback material.<br>
<br>I think yes.&nbsp; If there is an appropriate default value, we don&#39;t need a hint.&nbsp; This is similar to a text input with @value - a good value is already provided, and the &lt;label&gt; and context provides the rest of what you need.&nbsp; However, if there is *not* an appropriate default value, the current practice makes this known *only* to the server-side script.&nbsp; The UA has no way of knowing that the &lt;select&gt; is officially in an invalid position at the moment, and so can&#39;t provide automatic validation help (like it can with &lt;input @pattern&gt;).<br>
<br>So that&#39;s the only problem we really have to solve - how to tell the UA that the first &lt;option&gt; in the &lt;select&gt; is invalid.&nbsp; We Two things present themselves to me.<br><br>(1) Allow @hint as a boolean attribute on the first &lt;option&gt;.&nbsp; This is nothing more than what I said above - a hint to the UA that the first &lt;option&gt; in the list isn&#39;t a valid choice, so it should display as normal but not be submittable with this value.<br>
<br>(2) Put @hint as a text attribute on &lt;select&gt;.&nbsp; This would then display initially on the collapsed &lt;select&gt;.&nbsp; Upon selecting a value, the hint disappears and &lt;select&gt; acts like normal.<br><br>Option (1) is easy.&nbsp; However, it breaks symmetry with the proposed &lt;input&gt;/&lt;textarea&gt; @hint attribute.&nbsp; As well, it still provides an officially selectable attribute, even if the UA prevents the form from actually being submitted with it.&nbsp; The best user experience would be if the user simply couldn&#39;t select this.<br>
<br>Option (2) has some possibilities when we consider the fallback issue.&nbsp; For legacy UAs we must allow a &#39;default&#39; value that the server can detect, and this should be expressed as the first &lt;option&gt; to match current strategies, so that it will be automatically submitted if the user makes no choice.&nbsp; We can exploit this.&nbsp; I think it&#39;s reasonable to say that if @hint is specified on the &lt;select&gt;, and the first &lt;option&gt; has no text within it, the UA can choose to *not display* that first &lt;option&gt;.&nbsp; This produces exactly what we want - an initially displayed hint that disappears as soon as the user actually interacts with the control, just like @hint works on a text input.&nbsp; In legacy UAs that don&#39;t understand @hint, they&#39;ll simply display a blank &lt;option&gt; initially, which will be submitted with the author-supplied default value (so &quot;&quot; isn&#39;t reserved as the default and unusable as an actual value).&nbsp; This is a reasonable fallback method, and is used today in many cases.<br>
<br>To jump to another issue, I do *not* believe the hint should be displayed when the &lt;select&gt; is expanded.&nbsp; That&#39;s similar to displaying the hint when the user has focused a text input.&nbsp; If you need any help inside of a &lt;select&gt;, you have &lt;optgroup&gt;, which is more flexible.&nbsp; You can wrap all the &lt;option&gt;s in an &lt;optgroup&gt; if you really need text in the expanded &lt;select&gt;.<br>
<br>So, pulling it all together, my proposal for a hinting ability on &lt;select&gt; is thus:<br><br>&lt;select&gt; can have a @hint attribute, which takes a text value.&nbsp; If there is no &lt;option @selected&gt;, then this hint is initially displayed in the &lt;select&gt;&#39;s collapsed state.&nbsp; As soon as an option is selected, though (or if an &lt;option&gt; had @selected initially), the hint disappears and the selected &lt;option&gt;&#39;s text is instead displayed in the &lt;select&gt;&#39;s collapsed state.&nbsp; When @hint is supplied, a conforming UA will not allow the form to be submitted until an option is selected (again, an &lt;option&gt; with @selected specified counts here), indicating in some way that a value in the &lt;select&gt; must be chosen (the exact method UAs use to indicate this to users is left undefined, but should be similar to how the UA alerts a user that an &lt;input&gt; with @required is empty and must be filled).<br>
<br>For fallback, authors should provide an empty &lt;option&gt; (or one containing only whitespace) with an appropriate default @value as the &lt;select&gt;&#39;s first child.&nbsp; If &lt;optgroup&gt;s are used, this &lt;option&gt; should come before them.&nbsp; Conforming UAs will not display this &lt;option&gt;.&nbsp; In legacy UAs, this will cause the &lt;select&gt; to initially display as blank in the collapsed state, and will submit the author-supplied default value as the value of the control if the user does not make a proper selection.<br>
<br>This sound good?<br><br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div style=""><div></div><div><br></div><div>I realize these are display issues rather than semantic issues, but I think it&#39;s appropriate to discuss them.</div>
</div></blockquote><div><br>Actually, I think they&#39;re very important issues that touch on more than just display - this is fundamental usability here.&nbsp; Thanks for bringing them up.&nbsp;</div><br>~TJ</div>