?
avatar brianteeman
brianteeman
2 Jul 2020

https://dequeuniversity.com/rules/axe/3.5/empty-heading

Screen readers alert users to the presence of a heading tag. If the heading is empty or the text cannot be accessed, this could either confuse users or even prevent them from accessing information on the page's structure.

An example of where joomla fails on this is the new user form as this line
<h2><?php echo $this->form->getValue('name'); ?></h2>
results in
<h2></h2>

There are many ways to resolve this

    1. Check if its a new or existing record and only display the heading if its existing
<?php if ($this->item->id != 0): ?>
	<h2><?php echo $this->form->getValue('name'); ?></h2>
<?php endif; ?>
    1. Display different text as the heading if its a new or existing record
<?php if ($this->item->id != 0): ?>
	<h2><?php echo Text::_('COM_USERS_VIEW_NEW_USER_TITLE'); ?></h2>
<?php else: ?>
	<h2><?php echo $this->form->getValue('name'); ?></h2>
<?php endif; ?>
  1. and probably a lot lot more
avatar brianteeman brianteeman - open - 2 Jul 2020
avatar joomla-cms-bot joomla-cms-bot - change - 2 Jul 2020
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 2 Jul 2020
avatar chmst chmst - change - 2 Jul 2020
Category Accessibility
avatar hans2103
hans2103 - comment - 2 Jul 2020

@brianteeman if I'm correct the public function for getValue of $this->form is declared in libraries/src/Form/Form.php

And this function has an optional default value of the field value is empty.

/**
* Method to get the value of a field.
*
* @param string $name The name of the field for which to get the value.
* @param string $group The optional dot-separated form group path on which to get the value.
* @param mixed $default The optional default value of the field value is empty.
*
* @return mixed The value of the field or the default value if empty.
*
* @since 1.7.0
*/
public function getValue($name, $group = null, $default = null)
{
// If a group is set use it.
if ($group)
{
$return = $this->data->get($group . '.' . $name, $default);
}
else
{
$return = $this->data->get($name, $default);
}
return $return;
}

Agree?

let me propose possible solution numer 4.
We can benefit the default value, instead of an if-then-else statement.

<h2><?php echo $this->form->getValue('name', null, Text::_('COM_USERS_VIEW_NEW_USER_TITLE')); ?></h2>

if no name is given, the default value (third parameter), will be used.
What do you think of this solution?

avatar hans2103
hans2103 - comment - 2 Jul 2020

@brianteeman Can you propose an alternative default value ?

avatar alikon alikon - change - 3 Jul 2020
Status New Closed
Closed_Date 0000-00-00 00:00:00 2020-07-03 19:12:15
Closed_By alikon
avatar joomla-cms-bot joomla-cms-bot - change - 3 Jul 2020
Closed_By alikon joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 3 Jul 2020
avatar joomla-cms-bot
joomla-cms-bot - comment - 3 Jul 2020

Set to "closed" on behalf of @alikon by The JTracker Application at issues.joomla.org/joomla-cms/29909

avatar alikon
alikon - comment - 3 Jul 2020

as per #29920


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/29909.

avatar brianteeman
brianteeman - comment - 3 Jul 2020

Please re-open - only one instance is fixed in that pr

avatar alikon alikon - change - 3 Jul 2020
Status Closed New
Closed_Date 2020-07-03 19:12:15
Closed_By joomla-cms-bot
avatar alikon alikon - reopen - 3 Jul 2020
avatar alikon
alikon - comment - 3 Jul 2020

right

avatar hans2103
hans2103 - comment - 3 Jul 2020
  • administrator/index.php?option=com_users&view=user&layout=edit
    #29920
  • administrator/index.php?option=com_languages&view=language&layout=edit
    #29939
avatar hans2103
hans2103 - comment - 5 Jul 2020

@brianteeman when more issues found, please inform me.

avatar brianteeman
brianteeman - comment - 5 Jul 2020

I had another look last night and I didnt see them - I was sure I found more than these two originally ;(

I will close it for now.

avatar brianteeman brianteeman - change - 5 Jul 2020
Status New Closed
Closed_Date 0000-00-00 00:00:00 2020-07-05 11:38:51
Closed_By brianteeman
avatar brianteeman brianteeman - close - 5 Jul 2020

Add a Comment

Login with GitHub to post a comment