- Issue created by @mglaman
- ๐ฎ๐ณIndia roshni upadhyay
roshni upadhyay โ made their first commit to this issueโs fork.
- ๐ฎ๐ณIndia roshni upadhyay
The issue with the API is that when a node is updated, the updated content is not reflected in the API response. Instead, the API continues to return the old data. This problem occurs because the following code retrieves data from the auto-save manager, which may not have the latest changes:
if ($body = $this->autoSaveManager->getAutoSaveData($entity)) { ['layout' => $layout, 'model' => $model, 'entity_form_fields' => $entity_form_fields] = $body; }
- ๐ฎ๐ณIndia roshni upadhyay
roshni upadhyay โ changed the visibility of the branch 3503199-published-checkbox-is to hidden.
- ๐ฎ๐ณIndia roshni upadhyay
roshni upadhyay โ changed the visibility of the branch 3503199-published-checkbox-is to hidden.
- ๐ฎ๐ณIndia roshni upadhyay
roshni upadhyay โ changed the visibility of the branch 3503199-published-checkbox-is to active.
- Merge request !638#3503199: Ensure checkbox values are converted to Boolean correctly โ (Merged) created by Unnamed author
- ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
Debugged this.
#5 is inaccurate AFAICT.
Debugging trail
- Create a fresh
node
withstatus: false
. Say, node 4. - Load it in Experience Builder at
/xb/node/4/editor
. Observe that the toggle is toggled on. - Put a breakpoint in the code that generates this form:
\Drupal\experience_builder\Controller\EntityFormController::form()
. Observe this is the return value:
Most importantly:#value === FALSE
. - In
\Drupal\Core\Render\Element\Checkbox::preRenderCheckbox()
, that's still the case. - โ ๏ธ However, that maps the
#return_value
Form API property to thevalue
attribute:
Element::setAttributes($element, ['id', 'name', '#return_value' => 'value']);
which results in
- Look at the corresponding FE code:
/ui/src/components/form/components/drupal/DrupalToggle.tsx
. It contains this:
<Toggle checked={!!attributes?.value}
โฆ which appears accurate but isn't. The
value
attribute for<input type="checkbox">
is very interesting ๐คช, see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox....So AFAICT the problem lies in
DrupalToggle
, which was introduced in ๐ Split form components into `Drupal`-prefixed behavioral wrappers and presentational components Needs work .
Looking at
/node/<nid>/edit
- checked "published" checkbox:
<input data-drupal-selector="edit-status-value" type="checkbox" id="edit-status-value" name="status[value]" value="1" class="form-checkbox form-boolean form-boolean--type-checkbox">
- unchecked "published" checkbox:
<input data-drupal-selector="edit-status-value" type="checkbox" id="edit-status-value" name="status[value]" value="1" checked="checked" class="form-checkbox form-boolean form-boolean--type-checkbox">
๐ That's the markup being generated outside of XB. That's the starting point for things we do on top.
Tentative conclusion: needs only front-end changes?
So AFAICT updating
DrupalToggle
should work? But- checked={!!attributes?.value} + checked={!!attributes?.checked}
didn't do the trick ๐
I'm getting lost between:
ui/src/components/form/components/Checkbox.tsx
ui/src/components/form/components/drupal/DrupalInput.tsx
ui/src/components/form/components/Toggle.tsx
ui/src/components/form/components/drupal/DrupalToggle.tsx
โฆ because all four of those (!!!) are dealing with the
checked
attribute ๐ AFAICT only the last 2 are relevant. I changed both like indicated above, without success.I've done the due diligence, and think it's now down to somebody who knows the Semi-Coupled theme engine well enough to finish it up. It probably takes them only minutes given the digging I've done so far ๐ค
- Create a fresh
- ๐ฎ๐ณIndia swarad07 Navi Mumbai, India
- checked={!!attributes?.value} + checked={!!attributes?.checked}
That should be the way, as the correct attribute to check should be `checked` and not `value`
However, the other issue seems to be that the `attributes.checked` is coming as `true` always.
I am guessing somewhere in the flow that the `value` parameter of `1` is getting associated with the `checked` HTML attribute as `true`.
Needs further digging.
- ๐ณ๐ฑNetherlands balintbrews Amsterdam, NL
I made an update to the
DrupalToggle
component in โจ Defining props for code components Active , then @jessebaker pointed me at this issue.Can someone, please, help me with steps to reproduce? We have solid investigation bits by Wim in #10 โ , but I'm having a hard time to see how to actually reproduce the problem โ unless it went away. (At the time of writing this comment, โจ Defining props for code components Active is not in, but I don't think that will fix this anyway.)
- ๐ง๐ชBelgium wim leers Ghent ๐ง๐ช๐ช๐บ
Added STR for using article nodes.
- ๐ฎ๐ณIndia roshni upadhyay
I have made some changes in
ui/src/components/form/components/inputBehaviors.tsx
which resolved the checkbox issue Still we have issue with moving a node from published to draft state. Need to check the checkbox value for onChange event as when we change any content it makes the checkbox published and also update the node status. - First commit to issue fork.
-
jessebaker โ
committed 04f56e6a on 0.x authored by
roshni upadhyay โ
Issue #3503199 by roshni upadhyay: `DrupalToggle` for `boolean_checkbox...
-
jessebaker โ
committed 04f56e6a on 0.x authored by
roshni upadhyay โ
Automatically closed - issue fixed for 2 weeks with no activity.