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

Bug in MetaWizard widget #620

Closed
pgerundt opened this issue Aug 6, 2019 · 13 comments
Closed

Bug in MetaWizard widget #620

pgerundt opened this issue Aug 6, 2019 · 13 comments
Assignees
Labels
Milestone

Comments

@pgerundt
Copy link

pgerundt commented Aug 6, 2019

Steps to reproduce:

  1. Add a new language
  2. Enter data
  3. Save

When deleting the recently added language, a JS error is thrown.

Cause: The metaDelete() method in core.js tries to re-enable the language in the select field:

opt.getElement('option[value=' + li.getProperty('data-language') + ']').removeProperty('disabled');

But the select field does not contain (disabled) language options of currently used languages.

Maybe the language should not be removed from the select field:

But instead the active languages should be added with the "disabled" attribute to the select:

$options[] = '<option value="' . $k . '">' . $v . '</option>';

Maybe something like this:
$options[] = '<option value="' . $k . '"' . ($this->varValue[$k] ? ' disabled="disabled"' : '') . '>' . $v . '</option>';
and removing the unset() in L166

@leofeyer leofeyer added the bug label Aug 7, 2019
@leofeyer leofeyer added this to the 4.4 milestone Aug 7, 2019
@leofeyer
Copy link
Member

I cannot reproduce this. Which browser and OS did you test?

@pgerundt
Copy link
Author

Really? The issue is totally independent from OS or browser. (I'm using Firefox, Chrome and Safari on MacOS.)
When deleting a language, the core.js tries to remove the "disabled" property from that language select option.
But currently used languages are not added to the select box AFTER SAVING.

Did you really click "save" after adding a new language?

@leofeyer
Copy link
Member

@pgerundt
Copy link
Author

Clean install of v4.7.7 and the bug still occurs.
We should track it down to either PHP or JS.

Question: After adding a language and saving, does "your" select element contain the recently added language as a disabled option item?

"Mine" doesn't, so the JS error is thrown.

@fritzmg
Copy link
Contributor

fritzmg commented Aug 14, 2019

Please improve your reproduction steps:

  • What Accept-Language is used in your requests?
  • How many website roots do you have in which languages?
  • Which language was pre-selected in the meta wizard?
  • Which language did you add and subsequently delete?

@pgerundt
Copy link
Author

I'm sorry, I didn't provide these informations before, because they don't seem to have impact on the bug:

  • The Accept-Language is de,en;q=0.7,en-US;q=0.3
  • I tested with a single website root in de then switched it to en and finally setup two roots with de and en
  • After uploading a file, the languages of the website roots are pre-selected (so de, then en and finally de and en)
  • Any language added cannot be deleted after saving

So to sum it up:

  • The error occurs in several C4.7.7 installations - even in a clean install. So it's not caused by any extension.
  • It doesn't matter how many website roots are present; event their language doesn't have an impact (except for the pre-selection).
  • The JS is correct, it tries to re-enable a language in the select field after deletion, but the PHP unset()s currently used languages. So the JS error occurs.
  • The error occurs in Firefox, Chrome and Safari on MacOS.

@fritzmg
Copy link
Contributor

fritzmg commented Aug 14, 2019

@leofeyer I can reproduce the error in Contao 4.7.7 using @pgerundt 's reproduction.

@fritzmg
Copy link
Contributor

fritzmg commented Aug 14, 2019

Hm, in fact, I cannot delete any language at any point... am I encountering a different error? The JavaScript error is

TypeError: n.getElement(...) is null
mootools.min.js,mooRainbow.min.js,chosen.min.js,simplemodal.min....-c2b8a5e1.js:7:35094

@pgerundt
Copy link
Author

Thank you!
Yep, that's the error.
If you take a look at the core.js L2329 and the MetaWizard.php L166 from my first posting, it's pretty clear why you cannot delete any languages:

MetaWizard.php doesn't add active languages to the select and core.js tries to re-enable this non-existing item.

Still wondering why it works @leofeyer ...

@leofeyer
Copy link
Member

@fritzmg Can you also reproduce it in the latest 4.8 branch?

@fritzmg
Copy link
Contributor

fritzmg commented Aug 15, 2019

Yeah, same error still happens in 4.8.x-dev (dac2ccc).

@pgerundt
Copy link
Author

Guess, it's been there since
5402a0c#diff-ad0d5d4cc8531e1b48a7c869d477982f

@leofeyer leofeyer modified the milestones: 4.4, 4.8 Aug 20, 2019
@leofeyer leofeyer self-assigned this Aug 20, 2019
@leofeyer
Copy link
Member

Fixed in ecbe36f. @pgerundt Thank you for debugging this one so thoroughly. 👍

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants