Skip to content

fix: support keyboard widget addition - #28

Open
kdoberst wants to merge 2 commits into
patternfly:mainfrom
kdoberst:allow-add-widget-keyboard-only
Open

kdoberst wants to merge 2 commits into
patternfly:mainfrom
kdoberst:allow-add-widget-keyboard-only

Conversation

@kdoberst

@kdoberst kdoberst commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Issue

Right now a keyboard user has no way to easily add a widget onto a dashboard. Widgets inside the "add widgets" section don't receive focus. This means that for a keyboard users, they cannot add a new widget or add back a widget they accidentally removed. See video below

Screen.Recording.2026-11-12.at.1.42.48.PM.mov

Changes Summary

  • Add a keyboard-operable button to each widget drawer card.
  • Keep the button visually hidden until focused so it does not compete with the existing drag affordance.
  • Add the selected widget to the top-left of the dashboard when activated.
  • Preserve the existing drag-and-drop interaction and restore the original drawer instructions.

Video after changes

Screen.Recording.2026-11-12.at.1.34.30.PM.mov

Testing

  • yarn test --runInBand
  • yarn lint:js
  • ./node_modules/.bin/tsc --build --force packages/module/tsconfig.json

@aferd aferd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review scoped to the keyboard-add code in this PR. The existing drag-and-drop interaction remains available.

icon={<PlusCircleIcon />}
aria-label={`Add ${config?.title || widgetType} widget to dashboard`}
isDisabled={isDisabled}
onClick={() => onAdd?.(widgetType)}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

onAdd is optional, but this new button is rendered even when no handler is passed. A standalone WidgetDrawer then exposes a focusable ‘Add ... widget’ action that does nothing when activated. Could we render the button only when onAdd is provided?

}, {} as ExtendedTemplateConfig);

handleTemplateChange(newTemplate);
setCurrentlyUsedWidgets(newTemplate.xl.map((item) => item.widgetType));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This update filters the newly added widget out of the drawer, which unmounts the button that the keyboard user just activated. Focus then falls back to the document body, so adding another widget loses their place. Could we move focus to the next available add button, or to the drawer close button when none remain, and cover that sequence in a test?

x: 0,
y: 0,
widgetType,
i: getWidgetIdentifier(widgetType),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

getWidgetIdentifier runs once per breakpoint here, so one keyboard-added widget gets a different ID in each layout. GridLayout.removeWidget removes by ID, meaning a widget removed at one width remains in the other layouts and reappears after resizing. Could we generate one ID before this loop and reuse it for every breakpoint?

@kdoberst
kdoberst requested a review from aferd November 24, 2026 16:12
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