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

Update float field so it uses step='any' by default #3122

Merged
merged 1 commit into from
Mar 17, 2022

Conversation

Joossensei
Copy link
Contributor

This way the amount of decimals after the comma isn't fixed by default

This way you don't have a fixed amount of numbers after the comma
@Joossensei Joossensei changed the title Update float field so it uses step='any' Update float field so it uses step='any' by default Mar 15, 2022
Copy link
Member

@bobdenotter bobdenotter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@bobdenotter bobdenotter merged commit 2d02f5d into master Mar 17, 2022
@bobdenotter bobdenotter deleted the bugfix/fix-step-float branch March 17, 2022 14:21
@bobdenotter bobdenotter changed the title Update float field so it uses step='any' by default Update float field so it uses step='any' by default Mar 21, 2022
dadaxr added a commit to dadaxr/core that referenced this pull request Mar 28, 2022
since v5.1.5, commit bolt#3122  when number field "mode" is "float" (which is by default), the step is "'any'" by default (note the single quote wrapped by the double quote).  
This "'any'" value should not be escaped because it breaks when the number field is used within a collection. 

For instance, bellow is an extract of an "editor-collection" component generated by the backend when using a collection field having "number" field as child,
we can see it use a :template prop filled with escaped templates of fields members : 
```
 <editor-collection
      :existing-fields='[]'
      :templates='[{ ..  &lt;editor-number  ...  value=\&quot;\&quot;\n    :step=\&quot;&amp;bolt#39;any&amp;bolt#39;\&quot;\n    ...'
      :labels='...'
      :limit='200'
      :name="&quot;gallery_slider_images&quot;"
      :variant="&quot;collapsed&quot;"
    ></editor-collection>
```

Without applying a |raw filter, the value is double encoded and generates :
 
`:step=\&quot;&amp;bolt#39;any&amp;bolt#39;\&quot;`  (which decoded is the same as `:step=\"&bolt#39;any&bolt#39;\"`

instead of `:step=\&quot;&bolt#39;any&bolt#39;\&quot;` (which decoded is the same as `:step=\"'any'\"`)

This leads to a vue compilation error : 

```
[Vue warn]: Error compiling template:
 ...
<editor-number :id='&quot;field-gallery_slider_images-slider_image_set-6241de74820e3-coord_y&quot;' name="collections[gallery_slider_images][slider_image_set][6241de74820e3][coord_y]" value="" :step="&bolt#39;any&bolt#39;" :required="false" :readonly="false" :errormessage="false" :pattern="false" :placeholder="&quot;&quot;" ></editor-number>
...
- invalid expression: expected expression, got '&' in &bolt#39;any&bolt#39; Raw expression: :step="&bolt#39;any&bolt#39;"
```

However when using number field directly (ie without a collection field) it's was working. 

Using the |raw filter makes it work in both cases.

Note : this regression can lead to data loss when saving broken collections ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants