-
Notifications
You must be signed in to change notification settings - Fork 798
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
Widget visibility: Button doesn't work when admin screen loads with no widgets #12302
Comments
I tested this and I confirm this is indeed an issue. I tried some fixes but failed. Would love to work on this if I get some initial direction from developers. Steps to reproduce:
There's "something" that happens during "refresh" that helps the button to work. If we could replicate that "something" right when a widget gets added to the widget area or when a widget gets auto-saved, we could potentially fix this. |
Do you experience similar issues under Appearance > Customize > Widgets? |
Nope. It works fine in the customizer. disappears and continues troubleshooting based on this new information |
I was curious about this one, so dug in and found the issue is related to how widget-visibility checks if we are in the customizer or widgets.php. When no widgets are selected, the script thinks we are in the customizer. So the script doesn't actually run on newly added widgets until the page is reloaded after a widget is added. Applied a potential fix in #13858 |
* Fix logic for choosing customizer or widgets.php This commit changes the logic for determining whether we are in the customizer or widgets.php. Previously, when accessing widgets from widgets.php, the logic failed to recognize this when the page initialized with no widgets. This change removes the additional check for .widget-control-actions when initializing the widgets_shell variable. Instead we make sure the variable is not undefined, and if it is not undefined, we make sure it is not empty. This ensures the correct element is selected, even when there are no initial active plugins. See #12302 for details. * Bumps version in widget admin setup Bumps version number in widget_admin_setup function to ensure everyone gets updated file after plugin update. See #13858 (review)
When widget visibility is enabled and widgets are added to a completely empty Appearance > Widgets screen, the Visibility button doesn't work, instead the browser behaves as if you've clicked a link with
href="#"
. Once the page has been reloaded with at least one widget present, the Visibility button does to work. I suspect that the click event for the visibility button/link is not added to a new widget unless at least one widget is already present on DOM ready or on page load.Steps to reproduce the issue
What I expected
The visibility settings form is added to the widget, allowing me to adjust visibility settings.
What happened instead
A hash (
#
) is appended to the URL and the browser scrolls to the top of the page. No visibility settings form appears.Screenshots
If applicable, add screenshots to help explain your problem.
The text was updated successfully, but these errors were encountered: