Skip to content

Commit

Permalink
fix: bbox input becomes valid after deleting its value in search dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonKhorev committed Oct 13, 2023
1 parent 143cb10 commit fda20f5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/fetch-dialog/dynamic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,10 @@ export default abstract class DynamicNoteFetchDialog extends NoteFetchDialog {
private validateBbox(): boolean {
if (!this.$bboxInput) return true
const value=this.$bboxInput.value.trim()
if (!this.withBboxRequiredWhenPresent && value=='') return true
if (!this.withBboxRequiredWhenPresent && value=='') {
this.$bboxInput.setCustomValidity('')
return true
}
const lead=this.withBboxRequiredWhenPresent?``:`if provided, `
const splitValue=value.split(',')
if (splitValue.length!=4) {
Expand Down
11 changes: 11 additions & 0 deletions test-browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,17 @@ describe("browser tests",function(){
await this.assertText(page,"the-first-note")
await this.assertNoText(page,"the-second-note")
})
it("considers bbox value valid after entering and deleting text in search tab",async function(){
const page=await this.openPage()
const fetchButton=await this.waitForFetchButton()
const bboxInput=await page.$('#tab-panel-Search input[name=bbox]')
await bboxInput.type('x')
await page.keyboard.press('Backspace')
assert.notEqual(
await page.$('#tab-panel-Search input[name=bbox]:valid'),
null
)
})

// keyboard controls

Expand Down
3 changes: 3 additions & 0 deletions tools/osm-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ export default async function runOsmServer(authRedirectUrl,port=0) {
get config() {
return [{
web: this.url,
api: {
noteSearchBbox: true
},
tiles: `${this.url}{z}/{x}/{y}.png`,
note: `Test server bundled on ${new Date().toISOString()}`,
oauth: {
Expand Down

0 comments on commit fda20f5

Please sign in to comment.