Skip to content

fix(ui): move click handlers to ButtonBase for keyboard accessibility#5821

Open
eren-karakus0 wants to merge 2 commits intoFlowiseAI:mainfrom
eren-karakus0:bugfix/canvas-header-keyboard-accessibility
Open

fix(ui): move click handlers to ButtonBase for keyboard accessibility#5821
eren-karakus0 wants to merge 2 commits intoFlowiseAI:mainfrom
eren-karakus0:bugfix/canvas-header-keyboard-accessibility

Conversation

@eren-karakus0
Copy link

Summary

Fixes #5819

The toolbar buttons in CanvasHeader (Back, Edit Name, Save Name, Cancel, API Endpoint, Save Chatflow, Settings) had their onClick handlers bound to the inner Avatar component, which renders as a <div>. Since <div> elements are not keyboard-focusable by default, pressing Enter or Space on a focused ButtonBase did not trigger the click handler.

This PR moves all onClick handlers from the inner Avatar to the outer ButtonBase component, which renders as a <button> element and is natively keyboard-interactive.

Changes

  • File: packages/ui/src/views/canvas/CanvasHeader.jsx
  • Moved onClick from Avatar to ButtonBase for all 7 toolbar buttons
  • No behavioral changes for mouse users - click events still propagate correctly

How to test

  1. Open any chatflow in the canvas editor
  2. Use Tab key to navigate to toolbar buttons (Back, Save, Settings, etc.)
  3. Press Enter or Space - the button action should now trigger
  4. Verify mouse clicks still work as before

Note: The same pattern (ButtonBase > Avatar with onClick on Avatar) also exists in MarketplaceCanvasHeader.jsx, CustomAssistantConfigurePreview.jsx, EditNodeDialog.jsx, and Header/index.jsx. These could be addressed in follow-up PRs if desired.

…ccessibility

Move onClick event handlers from inner Avatar (div) elements to outer
ButtonBase (button) elements in CanvasHeader toolbar buttons. This
enables keyboard users to trigger button actions with Enter/Space keys,
as div elements are not focusable by default. Fixes all 7 toolbar
buttons: Back, Edit Name, Save Name, Cancel, API Endpoint, Save
Chatflow, and Settings.

Fixes FlowiseAI#5819
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @eren-karakus0, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the keyboard accessibility of the canvas editor's toolbar buttons by correctly associating their interactive behavior with the appropriate HTML elements. By relocating click handlers to the ButtonBase components, users navigating with a keyboard can now properly activate critical actions such as 'Back', 'Save', and 'Settings', leading to a more inclusive user experience.

Highlights

  • Improved Keyboard Accessibility: Moved onClick handlers from Avatar components to their parent ButtonBase components for all toolbar buttons in CanvasHeader.jsx. This ensures that pressing Enter or Space on a focused button now correctly triggers its action, addressing a keyboard accessibility issue.
  • No Behavioral Changes for Mouse Users: The change maintains existing functionality for mouse users, as click events continue to propagate correctly to the ButtonBase components.
  • Identified Further Improvements: Noted that similar accessibility improvements could be applied to other files like MarketplaceCanvasHeader.jsx, CustomAssistantConfigurePreview.jsx, EditNodeDialog.jsx, and Header/index.jsx in future pull requests.
Changelog
  • packages/ui/src/views/canvas/CanvasHeader.jsx
    • Moved onClick handler for the 'Back' button from Avatar to ButtonBase.
    • Moved onClick handler for the 'Edit Name' button from Avatar to ButtonBase.
    • Moved onClick handler for the 'Save Name' button from Avatar to ButtonBase.
    • Moved onClick handler for the 'Cancel' button (for name editing) from Avatar to ButtonBase.
    • Moved onClick handler for the 'API Endpoint' button from Avatar to ButtonBase.
    • Moved onClick handler for the 'Save Chatflow' button from Avatar to ButtonBase.
    • Moved onClick handler for the 'Settings' button from Avatar to ButtonBase.
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly addresses an important accessibility issue by moving onClick handlers from non-interactive Avatar components to their parent ButtonBase components. This ensures that the toolbar buttons are keyboard-focusable and can be triggered with Enter or Space. The changes are applied consistently across all relevant buttons in CanvasHeader.jsx. I have one suggestion to improve code readability by extracting a multi-line event handler into a named function. Overall, this is a solid fix that improves the user experience for keyboard users.

Comment on lines +259 to +265
onClick={() => {
if (window.history.state && window.history.state.idx > 0) {
navigate(-1)
} else {
navigate('/', { replace: true })
}
}}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For improved readability and to keep the JSX cleaner, you could extract this logic into a named function within the CanvasHeader component.

For example, you could define:

const handleBackClick = () => {
    if (window.history.state && window.history.state.idx > 0) {
        navigate(-1);
    } else {
        navigate('/', { replace: true });
    }
};

And then use onClick={handleBackClick} in the ButtonBase component. This is especially helpful for logic that isn't a simple one-liner and improves maintainability.

Copy link
Author

@eren-karakus0 eren-karakus0 Feb 22, 2026

Choose a reason for hiding this comment

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

Extracted it into a named handleBackClick function, consistent with the existing handler pattern in the component (submitFlowName, onAPIDialogClick, etc). Fixed in 5c58b66.

Extract the multi-line back navigation logic from inline onClick into a
named handleBackClick function for improved readability, consistent with
other handlers in the component (submitFlowName, onAPIDialogClick, etc).
@rvasilero
Copy link

Tested and It worked very well. Thank you very much. Also the other buttons should be repaired in the same way. I discovered other accesibility problems too, but I will make issues with them and kind of solution. Thank you very much for your openess to solve accesibility problems.

@eren-karakus0
Copy link
Author

Thank you for testing! Glad it works well. I noted the same pattern in other files (MarketplaceCanvasHeader, CustomAssistantConfigurePreview, EditNodeDialog, Header) - happy to submit follow-up PRs for those once this one is merged. Looking forward to the new issues you'll open, accessibility improvements are important.

@eren-karakus0
Copy link
Author

Friendly ping - this has been tested and confirmed working by the issue reporter. Just checking if there's anything else needed for review. Happy to address any feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ui Issues or features related to ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Misplaced click event in chat flow window

3 participants