atk4/ui

TreeView not marking saved value

mkrecek234 opened this issue · 6 comments

Steps to reproduce:

  • You have a form with a TreeView linked to a field, say article_group_id
  • You edit an entity in the form, select a valid entry of the TreeView
  • You click "Save"
  • The record is saved propery, including the article_group_id
  • You open/reload the edit form completely, showing the same record.

Issue:

  • The TreeView does not mark the currently selected entry/article_group_id

Expected behaviour:

  • The correct selected value inside the tree is marked with a black bullet.

This worked properly prior the latest develop commits

TreeView needs a Behat test to prevent breaking it in the future again.

Strange but working again without a change on Atk4 side as it seems, closing this issue

Thank you for the feedback.

I identified the issue which persists. Once again, it is a result of all id typecasting which is being done incorrectly, as an integer is passed to the vue component as a typecasted value with thousand separator. @mvorisek
I believe we should think about getting rid of this, as $model->idField as integers normally should never be typecasted with thousandSeparators. ThousandSeparators is a UI topic ONLY and should ideally only affect displayed values to the customers, whereas any data layer below is not affected by that. @mvorisek

Also if I do not find the time yet to provide your requested behat tests, here is the essence of the issue after further analysis:

  • The input field contains the typecasted id of the selection, e.g., id= 1.750 if you have a thousandSeparator .
  • Even if you ensure that all treeItems ids are ALSO typecasted, the Vue TreeItemSelector is not capable if marking the selected item correctly, as it cannot treat ids like 1.750 as they are no longer integers, even though they match the input field.

Consequence: TreeItemSelector requires a proper integer idfield, so current typecasting logic implemented will break this View if you have a thousandSeparator set. The only working workaround is #2022 , otherwise we have to change the logic how id fields are typecasted (or not) on hidden system fields in HTML.

About your 2nd point - why? please point to vue code, as ID can be a string like UUID or any other string.