rules repository

A-1120 Always define an icon for buttons using an icon template.

Severity Warning Check + SQL-based Test Free New

Reason

The Text with Icon button template renders the label next to an icon, and the Icon template renders only an icon. If no icon is set, a Text with Icon button shows only the text with a gap where the icon should be, and an Icon button renders as an empty button. Both look broken and inconsistent with the other buttons of the page.

Set the Icon attribute of the button. If the button should show only text, switch it to the plain Text template.

Example

Non-Compliant Example

page 10 (
    // ...
    button save (
        buttonName: SAVE
        label: Save
        // ...
        appearance {
            buttonTemplate: @/text-with-icon
            // no icon
        }
    )

    button close (
        buttonName: CLOSE
        label: Close
        // ...
        appearance {
            buttonTemplate: @/icon
            // no icon
        }
    )
)
Issues
LineColumnMessage
829Button uses the "Text with Icon" template but has no icon.
1829Button uses the "Icon" template but has no icon.

Compliant Solution - ★★★★★

page 10 (
    // ...
    button save (
        buttonName: SAVE
        label: Save
        // ...
        appearance {
            buttonTemplate: @/text-with-icon
            icon: fa-save
        }
    )

    button close (
        buttonName: CLOSE
        label: Close
        // ...
        appearance {
            buttonTemplate: @/icon
            icon: fa-close
        }
    )
)

Tests

Test SQL query

select aa.workspace || '.' || aa.alias || '.' || b.page_id || '.' || coalesce(b.static_id, to_char(b.button_id)) as identifier,
       'Button ' || b.button_name || ' on page ' || b.page_id || ' of app ' || aa.alias || ' in '
         || aa.workspace || ' uses the "' || b.button_template || '" template but has no icon.' as message
  from apex_application_page_buttons b
  join apex_applications aa
    on aa.application_id = b.application_id
       and aa.workspace = b.workspace
 where aa.workspace in (#ApexWorkspaces#)
   and b.button_template in ('Text with Icon', 'Icon')
   and b.icon_css_classes is null

Test results

IdentifierMessageMigration
WORKSPACE.CUSTOMERS.10.closeButton CLOSE on page 10 of app CUSTOMERS in WORKSPACE uses the "Icon" template but has no icon.-
WORKSPACE.CUSTOMERS.10.saveButton SAVE on page 10 of app CUSTOMERS in WORKSPACE uses the "Text with Icon" template but has no icon.-

Parameters

Use parameters to customize the rule to your needs.

ParameterDescriptionDefault Value
ApexWorkspacesComma-separated List of APEX workspaces owning APEX applications to check.dblinter, dbl_gui

References