Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geomap: Issues when used within form #8788

Open
jamespardey opened this issue Dec 12, 2019 · 8 comments
Open

Geomap: Issues when used within form #8788

jamespardey opened this issue Dec 12, 2019 · 8 comments

Comments

@jamespardey
Copy link

I've been using Geomap to select areas in forms, and for the sake of layout it's often easier to place the geomap within the form element itself. The new 4.0.31 unfortunately has a few minor issues for this usage:

The help button does not have a "type" attribute, causing it to act as a submit button by default.

The "step" parameter for the area of interest inputs will often cause the form to be marked invalid when an area is selected with the "Draw" button.

I've been able to replicate these issues on the working example page (v4.0.33 dev, it appears) simply by changing the <section> tags around the first geomap to <form>, within Firefox inspector.

For anyone else encountering the same issues, I've found a few quick kludges:

To prevent the button from submitting, add the following script (after jQuery has been loaded)

<script type="text/javascript">
$(document).on("wb-ready.wb", function() {
    $(".geomap-help-btn button").attr("type", "button")
})
</script>

With the WET-BOEW form validation plugin, if you're not using the AOI form results directly and transferring them to a different lat/lon entry field, the entire map can be ignored by the validator by adding its fields to the "ignore" selector. For example:
<div class="wb-frmvld" data-wb-frmvld=' { "ignore":":hidden, .wb-geomap input" } '>

@duboisp duboisp added Feature: Geomap Need: Replicate issue Need to replicate the described issue in a independent environment. Usually different of the author. Query: Question labels Jan 10, 2020
@duboisp
Copy link
Member

duboisp commented Jan 10, 2020

<form> element should not be used as a grid for layout.

What kind of layout are your expecting? Is there a reason you can't achieve your desired layout with the CSS grid?

@duboisp duboisp added Need: More information Not enough information provided in the issue to take an action that would resolve it. and removed Need: Replicate issue Need to replicate the described issue in a independent environment. Usually different of the author. labels Jan 10, 2020
@jamespardey
Copy link
Author

To clarify, I'm not using <form> for layout, and it has no layout attributes. The geomap in use is within a form, to select an area for the request . It would be possible to move the geomap outside of the form, since the extent change event is being used, but would make the connection less direct.

The issues are, when a geomap is used within a form:

  • The help button acts as a form submission button.
  • With the AOI widgets enabled, on selecting an extent with the "Draw" option, the user coordinate entry fields are considered invalid, seemingly due to the "step" attribute being of coarser resolution than the data from the drawn area.

I was able to observe these in a browser inspector tool, by changing the <section> tag containing "Dynamic Map Example" to a <form> tag, on the Geomap - Working Example page. Then

  • Pressing the ? will cause the browser to attempt to submit the form, reloading.
  • Trying again, but first selecting an area-of-interest prior to pressing the ? will generally not submit, but instead give a default html5 validation error on the lat/lon inputs, since the values are probably not going to be a multiple of the step attribute.

@duboisp
Copy link
Member

duboisp commented Jan 28, 2020

@jamespardey are you able to submit a PR?

With the AOI widgets enabled, on selecting an extent with the "Draw" option, the user coordinate entry fields are considered invalid, seemingly due to the "step" attribute being of coarser resolution than the data from the drawn area.

What kind of precision is needed? How many decimal precision number you need for your use case? Currently it is configured to support up to 6 decimal precision. See: https://github.com/wet-boew/wet-boew/blob/master/src/plugins/deps/geomap-lib.js#L1172

@duboisp duboisp added Query: Feature Request and removed Need: More information Not enough information provided in the issue to take an action that would resolve it. labels Jan 28, 2020
@jamespardey
Copy link
Author

I should be able to submit a PR in a week or so, provided I don't run into any issues getting the development environment set up.

As far as precision, our requirements are very coarse at the moment. 3 or 4 digits is more than enough. I imagine many users would need more precision than us.

Would rounding or truncating the AOI value to the step value in the 'boxend' callback (at least for the entry boxes) be an option?

@jamespardey
Copy link
Author

Sorry, I'd intended to submit a PR a lot earlier. I'll be submitting with a different account, @jpardey, from personal equipment.

The "help button type" issue is very simple to fix, and shouldn't require any additional documentation.

For the step value rounding, a sensible approach seems to be to pull the step value from each input, and round the value from the box select to a multiple of that step. In making as few assumptions as possible to the value of step (say, 0.0002 or 0.00025), it might be a bit more complex than it needs to be, but seems more future-proof and user-proof. I can't see any changes that would be needed for the documentation. Any thoughts?

I didn't realize those commits would pop up in this thread. There are a few slight changes I'd like to make to the rounding code before submitting a PR.

Since this is basically two (very small) fixes, would you prefer one or two PRs for this?

jpardey added a commit to jpardey/wet-boew that referenced this issue May 5, 2020
@GormFrank
Copy link
Contributor

Whenever you do a PR for this, do not forget to mention this issue in reference. Thank you!

jpardey added a commit to jpardey/wet-boew that referenced this issue May 26, 2020
@jpardey
Copy link
Contributor

jpardey commented May 26, 2020

Thanks @GormFrank , and sorry for taking so long to submit such a minor patch, @duboisp .

Regarding the PR I finally submitted ( #8869 ):
I'd initially added a method to round depending on the step value, in case the user were to attempt to change it via scripting. That seemed pretty unlikely, though, and this just uses .toFloat(6). If it's needed I can integrate it again. It works with arbitrary step values, including with multiple significant figures (ie, 0.0025).

I'm not sure what documentation would be required, but I'd be happy to add to the English versions.

Tested on Windows (IE 11, Edge 41 and 83), Linux (FF 76), Mac (Safari 13), and Chrome 81 or 83 on all. I attempted to test on Safari for iPhone, but it seems like neither the AOI drawing or the help button is functioning. If this is a bug, I can investigate further.

duboisp added a commit that referenced this issue May 28, 2020
Geomap: Fix for #8788. Adds button type for Geomap help button, and…

Approved at the technical review
@duboisp
Copy link
Member

duboisp commented May 28, 2020

/cc @GormFrank

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants