Skip to content

fix(dropdown): Add support for aria-disabled items to dropdowns#130

Merged
mshriver merged 1 commit into
RedHatQE:mainfrom
hugohezel:hhezel/dropdown_support_aria_disabled
Jul 21, 2026
Merged

fix(dropdown): Add support for aria-disabled items to dropdowns#130
mshriver merged 1 commit into
RedHatQE:mainfrom
hugohezel:hhezel/dropdown_support_aria_disabled

Conversation

@hugohezel

@hugohezel hugohezel commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Make Dropdown.item_enabled() to treat PatternFly menu links with aria-disabled="true" as disabled. PatternFly's Menu docs document both isDisabled and isAriaDisabled as supported MenuItem states.
https://www.patternfly.org/components/menus/menu/#basic-menus

A concrete example of aria-disabled item can currently be seen on the /insights/remediations page:
Screenshot From 2026-07-21 13-13-26

@sourcery-ai

sourcery-ai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Treat PatternFly dropdown menu items with aria-disabled="true" as disabled, and extend tests to cover aria-disabled behavior for both enablement checks and selection exceptions.

Sequence diagram for Dropdown.item_enabled aria-disabled handling

sequenceDiagram
    participant Test as Test_dropdown
    participant Dropdown as Dropdown
    participant Browser as Browser
    participant Element as MenuItem

    Test->>Dropdown: item_enabled(item, close=True)
    Dropdown->>Element: item_from_locator(item)
    alt Element is input
        Dropdown->>Element: is_enabled()
        Dropdown-->>Test: is_el_enabled = Element.is_enabled()
    else Element is not input
        Dropdown->>Browser: classes(Element)
        Browser-->>Dropdown: class_list
        Dropdown->>Browser: get_attribute(aria-disabled, Element)
        Browser-->>Dropdown: aria_disabled_value
        Dropdown-->>Test: is_el_enabled = "pf-m-disabled" not in class_list and aria_disabled_value != "true"
    end
    Dropdown->>Dropdown: close() when close=True
Loading

File-Level Changes

Change Details Files
Update dropdown item enablement logic to consider aria-disabled items as disabled.
  • Extend non-input element enablement check to also read the aria-disabled attribute via browser.get_attribute.
  • Require that a menu item is both not styled with pf-m-disabled and not marked aria-disabled="true" to be considered enabled.
  • Preserve existing behavior for input elements by leaving their is_enabled-based check unchanged.
src/widgetastic_patternfly5/components/menus/dropdown.py
Add tests verifying aria-disabled items are treated as disabled for item_enabled and item_select.
  • Add assertion that item_enabled returns False for an aria-disabled menu link.
  • Add assertion that item_select on an aria-disabled item raises DropdownItemDisabled, similar to disabled items.
  • Keep existing tests for normal, disabled, and non-existent items intact to guard regressions.
testing/components/menus/test_dropdown.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • Consider extracting the disabled-state logic (CSS class and aria-disabled checks) into a dedicated helper method to avoid duplication and make future changes to the disabled criteria easier to maintain.
  • The comparison against the string 'true' for aria-disabled is very specific; if PatternFly or the DOM ever uses other truthy values (e.g., 'True', '1'), you may want to normalize or broaden the check to avoid subtle regressions.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider extracting the disabled-state logic (CSS class and aria-disabled checks) into a dedicated helper method to avoid duplication and make future changes to the disabled criteria easier to maintain.
- The comparison against the string 'true' for aria-disabled is very specific; if PatternFly or the DOM ever uses other truthy values (e.g., 'True', '1'), you may want to normalize or broaden the check to avoid subtle regressions.

## Individual Comments

### Comment 1
<location path="src/widgetastic_patternfly5/components/menus/dropdown.py" line_range="169-173" />
<code_context>
-            is_el_enabled = "pf-m-disabled" not in self.browser.classes(el)
+            is_el_enabled = (
+                "pf-m-disabled" not in self.browser.classes(el)
+                and self.browser.get_attribute("aria-disabled", el) != "true"
+            )

</code_context>
<issue_to_address>
**suggestion:** Consider handling case variations for `aria-disabled` values.

`get_attribute("aria-disabled")` may return values with different casing or even non-string types, depending on the driver. Converting the result to a string and lowercasing it before comparison (e.g. `str(...).lower() == "true"`) will make the check resilient to these variations.

```suggestion
        else:
            aria_disabled = self.browser.get_attribute("aria-disabled", el)
            is_el_enabled = (
                "pf-m-disabled" not in self.browser.classes(el)
                and str(aria_disabled).lower() != "true"
            )
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/widgetastic_patternfly5/components/menus/dropdown.py
@hugohezel

Copy link
Copy Markdown
Contributor Author

Failures in the pipelines seem un-related:
ValueError: Timeout got an unknown value '10s'

@mshriver

Copy link
Copy Markdown
Collaborator

Failures in the pipelines seem un-related: ValueError: Timeout got an unknown value '10s'

#126

agreed, I need to get this in.

@hugohezel
hugohezel force-pushed the hhezel/dropdown_support_aria_disabled branch from dbc07a2 to 5b92a32 Compare July 21, 2026 11:40
@mshriver
mshriver merged commit bf0eb01 into RedHatQE:main Jul 21, 2026
3 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants