Skip to content

pattern attribute for language propery is invalid #4813

@ericscheid

Description

@ericscheid

Currently, the input for the Language property is:

<input title="" pattern="/.+/" placeholder="en" type="text" value="">

That pattern is bad. The slashes should not be there (it's html, not javascript). It looks like that's the default pattern value from our function.

It should be more like this:

pattern="^[a-z]{2,3}(-[A-Z][a-z]{3})?(-[A-Z]{2})?$"

That, btw, also allows for the rare 3 letter regions, 4 letter scripts (e.g. Hant for traditional Chinese), and then the final 2 letter language. (We have both in the example drop-list for the input).


The default pattern attribute value is defined here, as a javascript literal, but should be as a string, and looks to be inserted as a string of the literal js regex:

valuePatterns : /.+/

The custom combobox for language is defined here, it looks to be using the default combobox pattern (which is itself bugged), should have pattern="^[a-z]{2,3}(-[A-Z][a-z]{3})?(-[A-Z]{2})?$" inserted.

return <div className='field language'>
<label>language</label>
<div className='value' data-tooltip-right='Sets the HTML Lang property for your brew. May affect hyphenation or spellcheck.'>
<Combobox trigger='click'
className='language-dropdown'
default={this.props.metadata.lang || ''}
placeholder='en'
onSelect={(value)=>this.handleLanguage(value)}
onEntry={(e)=>{
e.target.setCustomValidity(''); //Clear the validation popup while typing
this.handleFieldChange('lang', e);
}}
options={listLanguages()}
autoSuggest={{
suggestMethod : 'startsWith',
clearAutoSuggestOnClick : true,
filterOn : ['value', 'detail', 'title']
}}
/>
</div>
</div>;

The above 2 suggestions modulo a better understanding of React. I don't even know the assumed syntax for valuePatterns.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2 - minor feature or not urgentMinor bugs or less-popular featuresUI/UXUser Interface, user experiencebugWe say this works but it doesn'tsolution foundA solution exists; just needs to be appliedtweakSmall, non-breaking change

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions