Moved back to data-wd-key approach and fixed tests

This commit is contained in:
orangemug 2019-05-21 19:07:28 +01:00
parent 911549aca3
commit 1fec89b69e
4 changed files with 10 additions and 15 deletions

View file

@ -108,13 +108,6 @@ class NumberInput extends React.Component {
} }
render() { render() {
let wdProps = {};
if (this.props.wdKey) {
wdProps = {
"data-wd-key": this.props.wdKey
};
}
if( if(
this.props.hasOwnProperty("min") && this.props.hasOwnProperty("max") && this.props.hasOwnProperty("min") && this.props.hasOwnProperty("max") &&
this.props.min !== undefined && this.props.max !== undefined && this.props.min !== undefined && this.props.max !== undefined &&
@ -146,6 +139,7 @@ class NumberInput extends React.Component {
/> />
<input <input
key="text" key="text"
type="text"
spellCheck="false" spellCheck="false"
className="maputnik-number" className="maputnik-number"
placeholder={this.props.default} placeholder={this.props.default}
@ -154,7 +148,6 @@ class NumberInput extends React.Component {
this.changeValue(e.target.value) this.changeValue(e.target.value)
}} }}
onBlur={this.resetValue} onBlur={this.resetValue}
{...wdProps}
/> />
</div> </div>
} }
@ -162,13 +155,13 @@ class NumberInput extends React.Component {
return <div className="maputnik-number-container"> return <div className="maputnik-number-container">
<input <input
key="text" key="text"
type="text"
spellCheck="false" spellCheck="false"
className="maputnik-number" className="maputnik-number"
placeholder={this.props.default} placeholder={this.props.default}
value={this.state.value} value={this.state.value}
onChange={e => this.changeValue(e.target.value)} onChange={e => this.changeValue(e.target.value)}
onBlur={this.resetValue} onBlur={this.resetValue}
{...wdProps}
/> />
</div> </div>
} }

View file

@ -12,9 +12,10 @@ class MaxZoomBlock extends React.Component {
} }
render() { render() {
return <InputBlock label={"Max Zoom"} doc={latest.layer.maxzoom.doc}> return <InputBlock label={"Max Zoom"} doc={latest.layer.maxzoom.doc}
data-wd-key="max-zoom"
>
<NumberInput <NumberInput
wdKey="max-zoom"
allowRange={true} allowRange={true}
value={this.props.value} value={this.props.value}
onChange={this.props.onChange} onChange={this.props.onChange}

View file

@ -12,9 +12,10 @@ class MinZoomBlock extends React.Component {
} }
render() { render() {
return <InputBlock label={"Min Zoom"} doc={latest.layer.minzoom.doc}> return <InputBlock label={"Min Zoom"} doc={latest.layer.minzoom.doc}
data-wd-key="min-zoom"
>
<NumberInput <NumberInput
wdKey="min-zoom"
allowRange={true} allowRange={true}
value={this.props.value} value={this.props.value}
onChange={this.props.onChange} onChange={this.props.onChange}

View file

@ -191,7 +191,7 @@ describe("layers", function() {
var bgId = createBackground(); var bgId = createBackground();
browser.click(wd.$("layer-list-item:background:"+bgId)) browser.click(wd.$("layer-list-item:background:"+bgId))
browser.setValueSafe(wd.$("min-zoom", "input"), 1) browser.setValueSafe(wd.$("min-zoom", 'input[type="text"]'), 1)
browser.click(wd.$("layer-editor.layer-id", "input")); browser.click(wd.$("layer-editor.layer-id", "input"));
var styleObj = helper.getStyleStore(browser); var styleObj = helper.getStyleStore(browser);
@ -221,7 +221,7 @@ describe("layers", function() {
var bgId = createBackground(); var bgId = createBackground();
browser.click(wd.$("layer-list-item:background:"+bgId)) browser.click(wd.$("layer-list-item:background:"+bgId))
browser.setValueSafe(wd.$("max-zoom", "input"), 1) browser.setValueSafe(wd.$("max-zoom", 'input[type="text"]'), 1)
browser.click(wd.$("layer-editor.layer-id", "input")); browser.click(wd.$("layer-editor.layer-id", "input"));
var styleObj = helper.getStyleStore(browser); var styleObj = helper.getStyleStore(browser);