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

[5.2] Fix for: Article cannot be saved successfully on the front-end #44680

Merged
merged 1 commit into from
Jan 17, 2025

Conversation

NicolasDerumigny
Copy link
Contributor

@NicolasDerumigny NicolasDerumigny commented Jan 2, 2025

Pull Request for Issue #37106 (or, at least, an issue having the exact same symptoms and behaviour).

Summary of Changes

Modify the element used for button data selector when using any button of the com_content edit form on the front-end.

Testing Instructions

Modify an existing article using the front-end. Save by clicking specifically on the checkbox icon in the save button (so that the event.target is the span.icon-check).

Actual result BEFORE applying this Pull Request

The article is not saved, as the POST request sent to the server has an empty task field.

Expected result AFTER applying this Pull Request

The article is correctly saved.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@joomla-cms-bot joomla-cms-bot added NPM Resource Changed This Pull Request can't be tested by Patchtester PR-5.2-dev labels Jan 2, 2025
@fgsw
Copy link

fgsw commented Jan 2, 2025

@NicolasDerumigny Can you change the title of the Pull Request to something more meaningful cause the title will be used in the changelog.

Maybe something like "[5.2] Fix for: Article cannot be saved successfully".

@NicolasDerumigny NicolasDerumigny changed the title Fix #37106 [5.2] Fix for: Article cannot be saved successfully Jan 2, 2025
@NicolasDerumigny
Copy link
Contributor Author

Of course. That's done!

@fgsw
Copy link

fgsw commented Jan 4, 2025

Save by clicking specifically on the checkbox icon in the save button (so that the event.target is the span.icon-check).

Can you provide a screenshot where to click or explain in another way?

@NicolasDerumigny
Copy link
Contributor Author

NicolasDerumigny commented Jan 4, 2025

Of course. JavaScript set in event.target the element that is clicked, which may be a child of the element containing the handler (detailed explanation here: https://fr.javascript.info/bubbling-and-capturing). In my case, the save buttons are like this:
image
Which translate in the HTML syntax to (for a single button):

<button type="button" class="btn btn-primary" data-submit-task="article.apply">
   <span class="icon-check" aria-hidden="true"></span>
   Enregistrer 
</button>

Therefore, clicking on the "check" icon (corresponding to the span tag) triggers the save event with the span as event.target, which is used to determine the task using the data-submit-task property. As the span does not have it (only the button does), an empty string is transmitted in the POST request in the task variable and the bug occurs.

@fgsw
Copy link

fgsw commented Jan 4, 2025

Thanks but can you provide a screenshot where to click to get the bug?

@NicolasDerumigny
Copy link
Contributor Author

NicolasDerumigny commented Jan 4, 2025

Of course, it's on the blue section here (in the front-end only):
image

@fgsw
Copy link

fgsw commented Jan 4, 2025

I have tested this item ✅ successfully on 8e6ae5c

Test by using default 5.2.2 + prebuilt update package.

@NicolasDerumigny I haven't noticed its about the frontend. Can you update the test instructions like "Modify an existing article in the frontend."?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/44680.

@NicolasDerumigny NicolasDerumigny changed the title [5.2] Fix for: Article cannot be saved successfully [5.2] Fix for: Article cannot be saved successfully on the front-end Jan 4, 2025
@NicolasDerumigny
Copy link
Contributor Author

That's done! Let me know if you need anything else!

@C-Lodder
Copy link
Member

C-Lodder commented Jan 6, 2025

Note, you can also use e.currentTarget

@chmst
Copy link
Contributor

chmst commented Jan 15, 2025

I have tested this item ✅ successfully on 8e6ae5c

Before patch: Click on the icon itself: article is not saved. No warning no error.

After Patch: Article is saved with "success" message, as expected.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/44680.

@fgsw
Copy link

fgsw commented Jan 16, 2025

Can the PR get synced with the base branch and set as "Ready To Commit"?

@alikon
Copy link
Contributor

alikon commented Jan 16, 2025

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/44680.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Jan 16, 2025
@alikon alikon added the bug label Jan 16, 2025
@alikon
Copy link
Contributor

alikon commented Jan 16, 2025

Can the PR get synced with the base branch

a task for Mantainers / Release Manager

@fgsw
Copy link

fgsw commented Jan 16, 2025

a task for Mantainers / Release Manager

@alikon Thanks for info. I thought it has to be the other way round.

@NicolasDerumigny
Copy link
Contributor Author

I can do it, if this means "rebase to current 5.2-dev top"

@alikon
Copy link
Contributor

alikon commented Jan 16, 2025

oh yes, forgot to mention that the pr author can do it
@NicolasDerumigny if you do it i'll restore the RTC status

@NicolasDerumigny
Copy link
Contributor Author

There you go :)

@QuyTon
Copy link

QuyTon commented Jan 16, 2025

Why not change it as suggested here? #44680 (comment)

@NicolasDerumigny
Copy link
Contributor Author

In this case, both are strictly equivalent. I changed it that way to avoid confusion between currentTarget and target, and it is more natural for me to use button which is a constant in the context of the event function rather that the variable e, but this is clearly up to personal taste.

@Hackwar Hackwar merged commit ecb5151 into joomla:5.2-dev Jan 17, 2025
3 checks passed
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Jan 17, 2025
@Hackwar
Copy link
Member

Hackwar commented Jan 17, 2025

Thank you very much! Awesome find!

@Hackwar Hackwar added this to the Joomla! 5.2.4 milestone Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug NPM Resource Changed This Pull Request can't be tested by Patchtester PR-5.2-dev
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants