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

Widget visibility: Button doesn't work when admin screen loads with no widgets #12302

Closed
scottnelle opened this issue May 8, 2019 · 4 comments · Fixed by #13858
Closed

Widget visibility: Button doesn't work when admin screen loads with no widgets #12302

scottnelle opened this issue May 8, 2019 · 4 comments · Fixed by #13858
Assignees
Labels
[Feature] Extra Sidebar Widgets Good For Community [Pri] Low [Type] Bug When a feature is broken and / or not performing as intended
Milestone

Comments

@scottnelle
Copy link

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

  1. Go to Appearance > Widgets
  2. If any widgets are present in any of the defined sidebars, delete them and then refresh the page.
  3. Add any widget to any sidebar.
  4. In the new widget, click the "Visibility" link.

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.

@jeherve jeherve added [Pri] Low [Type] Bug When a feature is broken and / or not performing as intended [Feature] Extra Sidebar Widgets Good For Community labels May 8, 2019
@wigglemuff
Copy link
Contributor

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:

  1. Go to the widgets page, remove all widgets from the widget area and refresh the page (imp step).
  2. Add a widget, hit visibility button, it doesn't work
  3. Refresh the page, hit visibility button, it works!

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.

@jeherve
Copy link
Member

jeherve commented Oct 7, 2019

There's "something" that happens during "refresh" that helps the button to work.

Do you experience similar issues under Appearance > Customize > Widgets?

@wigglemuff
Copy link
Contributor

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

@chickenn00dle
Copy link
Contributor

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

@jeherve jeherve modified the milestone: 8.0 Nov 19, 2019
@jeherve jeherve added this to the 8.1 milestone Dec 2, 2019
jeherve pushed a commit that referenced this issue Dec 2, 2019
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Extra Sidebar Widgets Good For Community [Pri] Low [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants