Problem/Motivation
In #2781575: Determine ideal field order and visibility for "quick edit" blocks in off canvas tray and UX meeting it was determined that the "Title" field on the block for is confusing. Often times the block title is not displayed but the user can still change it.
Also "title" is confusing because is it the title of the site(when used on branding block) or the title just for the block.
Here is a screen of the unpatched module. This shows a block with the block title not displayed.
You can see title input box is shown even though this will have not effect unless the user also checks "Display title"
Also "Title" and "Display Title" are not clear this is for the specific block.
Proposed resolution
Hide the title field if "Display Title" is not checked.
Change label to "Block Title" and "Display Block Title"
Here is screenshot the same block as above but with patched module
You can see that when the title is not displayed on the block then the title input is not shown.
The label for the checkbox is also changed to "Display Block Title"
Once you check the checkbox
You see the title input show up below the checkbox.
The input label is also changed to "Block Title"
Here is short video showing a unpatched and patched version https://youtu.be/hj5Rf2kxb24
Remaining tasks
Create patch
Add tests
Create screenshots
Create demo video
UX Review
User interface changes
See "Proposed resolution" above
API changes
None
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#14 | patched_title_checked.png | 19.42 KB | tedbow |
#14 | patched_no_title.png | 17.68 KB | tedbow |
#14 | title_current.png | 19.08 KB | tedbow |
#10 | 2882729-10.patch | 4.71 KB | tedbow |
#10 | interdiff-2882729-9-10.txt | 5.57 KB | tedbow |
Comments
Comment #2
tedbowHere are title related changes from #2781575: Determine ideal field order and visibility for "quick edit" blocks in off canvas tray
Also added comprehensive tests. The tests showed some need for changes to \Drupal\outside_in\Block\BlockEntityOffCanvasForm::processLabelInput()
To see what could go wrong look at \Drupal\Tests\outside_in\FunctionalJavascript\OutsideInBlockFormTest::testHiddenFormElements()
Comment #3
tedbowCleans up test class, I had commented out other test functions.
Changes label of input from "Title" to "Block Title"
Comment #4
tedbowComment #5
tedbowComment #6
tim.plunkettTechnically this whole thing should be wrapped in an
if (isset($form['settings']['label_display']) && isset($form['settings']['label'])) {
since it could theoretically not exist.get_class($this) can now be replaced by static::class
Is there a reason getUserInput is used instead of getValues?
required
This can be
$form_state->setValue(['settings', 'label'], $element['#value']);
These should all be // Inline comments.
Extra new line
Determines
isLabelInputVisible?
I don't understand this change
Comment #7
tedbow@tim.plunkett thanks for the review.
1. fixed
2. fixed
3. Yes added comment in code
I confirm this again by step debugging and changing to getValues() makes the test fail.
4. fixed
5. fixed
6. Fixed. was trying to make these comments stand out because they are major steps in the test but hopefully empty lines between the sections will be enough.
7. Think I found the line you were talking about and removed.
8. fixed
9. yes, thats better, Fixed
10. During making the changs I was getting weird test failures. It was because originally when wrote this test I thought that
$web_assert->waitForElementVisible('css', '#drupal-off-canvas')
Would actually cause a failure if the element was not visible after the wait. This was my mistake it just returns back NULL.
I just tested and it can be removed and test still pass.
So basically this just waits for the tray to open but doesn't fail if it doesn't open. Just things later that depend on it opening will fail.
So removed it. Will file follow up.
FOLLOW UP: #2883483: Assert that calls to waitForElementVisible() actually return element in OutsideIn javascript tests.
Comment #8
tedbowLooks like the reason I need to use getInput() as @tim.plunkett asked in #6.3. was because my local site had some problem.
I reinstalled and I don't need to and probably don't need #process at all.
Will update patch which should make it much simpler.
Comment #9
tedbowOk. so this removes the process callback for the label element. So now it is simply use the #states API.
I left the test in. The only thing I changed about the test is the part where checks that you can set the label to "" and then hide it. That will not work without the process callback but that seems a bit of a forced example.
Comment #10
tedbowThis removes the test testTitleInput(). We don't need this anymore because we are not doing anything special for processing of the title input.
We were already testing a block, system_powered_by_block, where label was hidden and then show it. So moved the checkbox test to there.
Also added to assertOffCanvasBlockFormIsValid() checking the labels are changed and the Block title input is not shown if checkbox is not checked.
Comment #11
tim.plunkettLooks great! Thanks @tedbow
Comment #12
catchThis could use UX review, and screenshots to make that review easier.
Comment #13
jibranNR as per #12
Comment #14
tedbowOk added screenshots and video to summary
Comment #15
Bojhan CreditAttribution: Bojhan as a volunteer and commentedLooks good to me, this leverages how we intent to use the pattern for hiding fields when they are not necessary to see.
Comment #16
webchickMakes a lot of sense. Does what it says on the tin, and comes with tests. Win!
Committed and pushed to 8.4.x and cherry-picked to 8.3.x. Thanks!
Comment #20
tedbowChanging to new settings_tray.module component. @drpal thanks for script help! :)