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

haste_ajax_operation does not work in Contao 5 due to new dark theme #227

Open
fritzmg opened this issue Sep 13, 2024 · 5 comments
Open

Comments

@fritzmg
Copy link
Collaborator

fritzmg commented Sep 13, 2024

In Contao 5 the dark theme was introduced. With this change the HTML structure of the toggle operation looks like this:

<a data-haste-ajax-operation-value="0" data-haste-ajax-operation-name="toggle" href="/contao?do=…" class="toggle" onclick="return Haste.toggleAjaxOperation(this, 1);Backend.getScrollOffset();" title="Unpublish element ID 1">
  <img src="/system/themes/flexible/icons/visible--dark.svg" width="16" height="16" alt="Publish/unpublish element" class="color-scheme--dark" loading="lazy">
  <img src="/system/themes/flexible/icons/visible.svg" width="16" height="16" alt="Publish/unpublish element" class="color-scheme--light" loading="lazy">
</a>

i.e. there are now two <img>. dca-ajax-operations.js however only applies the change to the first one:

const image = $(el).getFirst('img');

and only also only for the default (light) theme (so the action itself does work - just the icon is not replaced correctly).

Not sure what the best way to fix this is. Should the server return an additional nextIconDark which the JavaScript would then apply to the correct <img>?

@qzminski
Copy link
Member

Yeah… it would be best if you can use the Contao core features as described in the manual. Or is there a reason you can't do so?

@fritzmg
Copy link
Collaborator Author

fritzmg commented Sep 14, 2024

These are only available in Contao 5 (I think?). The extension in question still has Contao 4.13 compatibility.

@aschempp
Copy link
Collaborator

@fritzmg it is also available in Contao 4.13 (see contao/contao#3889).

It is still a bug though in Haste :/

@fritzmg
Copy link
Collaborator Author

fritzmg commented Oct 24, 2024

As a fix this feature within Haste could be removed and changed so that a loadDataContainer listener automatically changes the DCA to the variant compatible with Contao 4.13+? 😁

Otherwise I'd say it's probably not worth fixing.

@aschempp
Copy link
Collaborator

I think Haste supports more features and more complex handling. But I personally never had a use case for anything more than toggles, so I'm not planning on investing time on this fix 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants