When adding a new content type, you can decide the menu which nodes of that content type can belong to.
After the checkboxes that allow you to select these menus, there is the "default parent item" listbox which allows you to decide the default value for the "parent item" field shown when you add a node of that content type to a menu. This listbox is always shown, even if you haven't selected any of the checkboxes representing the available menus in a Drupal site.
Instead, it should be shown/hidden dynamically based on the selection of any of the checkboxes representing the various menus.
| Comment | File | Size | Author |
|---|---|---|---|
| #41 | menu-hidden-1829328.41.interdiff.txt | 523 bytes | larowlan |
| #41 | menu-hidden-1829328.41.patch | 1.01 KB | larowlan |
| #33 | Menu setting - parent display.png | 73 KB | solange_sari |
| #22 | menu-hidden-1829328.22.interdiff.txt | 1.07 KB | larowlan |
| #22 | menu-hidden-1829328.22.patch | 1 KB | larowlan |
Comments
Comment #1
falcon03 commentedTagging + Adding a more descriptive title
Comment #2
falcon03 commentedComment #3
falcon03 commentedSince the same problem happens with the "field widgets" form item shown when you add a new field, I wonder if this is a more abstracted issue related to the Form API...
Comment #4
cbHiding the menu when there is nothing to display is quite easy and have just updated the menu.admin.js to do this.
However, abstracting this to the form API is something that will require a little more work.
Adding a patch for the time being.
Comment #5
falcon03 commented@Christian Biggins: oh, thank you for the patch. Let's see if the bot likes it! :-)
Also tagging.
Anyway, if we could abstract this patch it would be really great because this is an issue that happens in many different places (especially in contrib)...
Comment #6
mgiffordBot liked it and it applied nicely to my local install. It's pretty simple JS, but might be good to have it reviewed especially in light of thinking about greater abstraction.
Comment #7
nod_+ $select.parents('div').first().hide();Shouldn't that be
+ $select.closest('div');We might want to get more specific than that for the selector. like
.form-itemor something.As far as abstracting that, not sure. But we could improve the speed of this thing by not using .append in the loop. It's not really good practice to begin with.
Comment #8
cbUpdated patch with closest() and not parents().
I'm not sure what would be a better practice than using append()? From my reading, its not totally inefficient. Feedback appreciated.
Comment #9
cbComment #10
nod_can you put the $select.closest('div') in a variable before the if? That kind of selector duplication is a pain to refactor afterwards.
Comment #11
mgifford#8: drupal8-menu_option_updates-1829328-8.patch queued for re-testing.
Comment #12
swentel commentedThis doesn't really belong to the field system.
Comment #13
mgifford#8: drupal8-menu_option_updates-1829328-8.patch queued for re-testing.
Comment #14
cbNow with added duplication avoidance!
Comment #15
mgiffordThis needs a JS review, but it's so very short. I've tested it in a Mac with FF, Safari, Chrome & Opera. Works as expected. I'm including a before/after shot.
I did have questions about the comments. The text will appear like this in the text:
But think this is more common.
Heck, maybe it could even go on one line.... :)
I think this will offer usability improvements too! Looks good.
Comment #16
mgiffordScreenshots as promised.
Comment #17
attiks commentedmissing ;
Comment #18
nod_Also, you can use .toggle()
instead of the if.
Comment #19
larowlanwill re-roll today
Comment #20
mgiffordOh ya, I think it would be better if you also added the HTML5 hidden attribute as per:
http://www.paciellogroup.com/blog/2012/05/html5-accessibility-chops-hidd...
Comment #21
cbBoth hidden and aria-hidden?
Comment #22
larowlanFrom the link
Just using hidden for now.
Comment #24
mgifford@Christian Biggins - the recommendations I've seen suggest just using HTML5's hidden attribute. I think that provides all the semantic information & is well supported by AT.
HTML5 supersedes ARIA where they serve the same purpose.
Comment #25
mgifford#22: menu-hidden-1829328.22.patch queued for re-testing.
Comment #27
mgiffordI'm trying to look at this test locally, but not sure which test to find this one under:
CollapsedDrupal\system\Tests\Upgrade\BlockUpgradePathTest
The problem is with Drupal\simpletest\WebTestBase->xpath('//li[@class=:class]', Array) called by simplexml_import_dom(): Invalid Nodetype to import
But I can't get to the full results to see what the test is failing over.
Comment #28
mgifford#22: menu-hidden-1829328.22.patch queued for re-testing.
Comment #29
cbSorry for lack of response on this. Looks like its all ok?
Comment #30
mgiffordJust tested the patch in #22 http://simplytest.me/project/drupal/8.x
It's working as expected.
Comment #31
catchJust to check on this bit:
It's not possible to test something on $select rather than keeping track of the totalOptions separately?
Comment #32
mgiffordIf I'm here - en/admin/structure/types/manage/article
And I go to the Console in Chrome, why do I get:
I'm just trying to see what other options there are other than incrementing a value in the loop.
Comment #33
solange_sari commentedGreat feature!!!
and it works properly as showed in the following picture
Comment #34
mgiffordPutting this back to needs review as we should address @catch's comments about totalOptions.
Thanks so much for the review @solange_sari very useful.
Comment #35
mgifford#22: menu-hidden-1829328.22.patch queued for re-testing.
Comment #36
mgifford#22: menu-hidden-1829328.22.patch queued for re-testing.
Comment #37
jessebeach commentedfrom #31
It seems fine to keep track of the options count this way, since the var is being used as a truthy test for the
toggleandattrmethods.Comment #38
mgiffordOk, I'm going to set it back to RTBC then.
Comment #39
xjm#22: menu-hidden-1829328.22.patch queued for re-testing.
Comment #40
alexpottNow we have jshint in core :)
Should be
===Comment #41
larowlanComment #42
andypostNice
Comment #43
alexpottCommitted 7ba4db0 and pushed to 8.x. Thanks!