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

Botton Set without refresh #1678

Closed
munirkamal opened this issue Nov 29, 2017 · 10 comments
Closed

Botton Set without refresh #1678

munirkamal opened this issue Nov 29, 2017 · 10 comments
Milestone

Comments

@munirkamal
Copy link

Issue description:

I've used buttons set to conditionally show/hide some controls. It works but with refresh, Is it possible to make it work without refresh? I've tried all 3 transport choices and without luck.

screen recording 2017-11-29 at 07 17 pm

Anyone got a solution for this, please?

Version used:

Latest stable version

Using theme_mods or options?

theme_mods

Code to reproduce the issue (config + field(s))

@aristath aristath added this to the 3.0.17 milestone Dec 2, 2017
@aristath
Copy link
Contributor

aristath commented Dec 2, 2017

Can you please check the develop branch?
I believe this was just fixed with a whole new implementation for field dependencies.

@aristath aristath closed this as completed Dec 2, 2017
@munirkamal
Copy link
Author

@aristath

Well, I just tried it and it still refreshes, do I need to pass any additional parameter or something I am missing? Please advice.

TIA

@aristath aristath reopened this Dec 4, 2017
@aristath
Copy link
Contributor

aristath commented Dec 4, 2017

Oh I'm sorry, I completely misunderstood the original post. My bad... Instead I refactored the field dependencies implementation.

Setting 'transport' => 'postMessage' in the site-layout control will prevent it from refreshing.

If that doesn't work can you please post the code you're using for that control and its dependent fields?

@munirkamal
Copy link
Author

Hi,

I tried it, and this works without refresh, but then we have another issue where values do not save properly and revert back while switching. Difficult to explain so I have created a demo site and demo screencast to explain better.

Code for the demo:
https://gist.github.com/munirkamal/17deb0a67eba34fc8ae3b5390b800e0a

Quick Screencast to explain the issue:
https://cl.ly/o6wg

Demo site, so you may test it yourself.
Login: http://tame-cheetah.w6.poopy.life/wp-admin/
Username: demo
Password: kmn9Z40hK4VP

Looking forward to your help.

TIA,
Munir

aristath added a commit that referenced this issue Dec 5, 2017
@aristath
Copy link
Contributor

aristath commented Dec 5, 2017

About the missing styles:
I can see in the browser console that the styles.min.css file is missing.
Are you by any chance modifying the URL of kirki? Perhaps using a kirki/config filter and defining url_path in there?

As for the output:
If a field is not shown, then its CSS is not used either because we assume that since you hide them, they no longer apply. The dependencies were not originally designed to be used as tabs which is why it works this way.

I just added 2 filters that will disable that default behaviour so you can use those:

add_filter( 'kirki/start/webfonts/skip_hidden', '__return_false' );
add_filter( 'kirki/start/css/skip_hidden', '__return_false' );

start of course is the config-ID you're using for your fields.

Once you add those 2 lines in your theme it should work the way you want it.

@munirkamal
Copy link
Author

Awesome, That worked perfectly.

Now only issue is with the missing CSS min file which looks like a bug in v3.0.17

@aristath
Copy link
Contributor

aristath commented Dec 6, 2017

Already fixed in the wordpress.org version. Delete your copy and redownload. It was a problem with the SVN push.
I'll fix in the repo here later today 👍

@aristath aristath closed this as completed Dec 6, 2017
@munirkamal
Copy link
Author

@aristath

Hi,

This seems like since v3.0.22 the filters solution you provided to make button groups work as tabs don't work. I can see in the changelog that you have removed webfonts.php and now use the json file.

Could you please suggest an updated solution to this use case? I have used this extensively in my theme and now If I update to latest version of kirki nothing works :(

Looking forward to your response.

TIA,
Munir

@aristath
Copy link
Contributor

Can you try using this instead of the previous filters?

add_filter( 'kirki_start_webfonts_skip_hidden', '__return_false' );
add_filter( 'kirki_start_css_skip_hidden', '__return_false' );

@munirkamal
Copy link
Author

Thank you, that did the trick.

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

2 participants