Skip to content

fix: Complete accessibility - move all onClick handlers from Avatar to ButtonBase#5846

Open
fuleinist wants to merge 1 commit intoFlowiseAI:mainfrom
fuleinist:fix/canvas-header-accessibility-complete
Open

fix: Complete accessibility - move all onClick handlers from Avatar to ButtonBase#5846
fuleinist wants to merge 1 commit intoFlowiseAI:mainfrom
fuleinist:fix/canvas-header-accessibility-complete

Conversation

@fuleinist
Copy link

Summary

This PR completes the accessibility fix for #5819 by moving all onClick handlers from Avatar (div) components to their parent ButtonBase (button) components.

Buttons Fixed:

  1. Back - navigate handler moved to ButtonBase
  2. Edit Name - setEditingFlowName(true) handler moved
  3. Save Name - submitFlowName handler moved
  4. Cancel - setEditingFlowName(false) handler moved
  5. API Endpoint - onAPIDialogClick handler moved
  6. Save - onSaveChatflowClick handler moved
  7. Settings - setSettingsOpen handler moved

Why This Matters:

  • Enables keyboard accessibility (Enter/Space keys work)
  • Important for keyboard-only users and screen reader users
  • Makes the application more inclusive and compliant with accessibility standards

Testing:

All buttons should now be triggerable using keyboard navigation (Tab to focus, Enter/Space to activate).

…ar to ButtonBase

- Back button: navigate handler moved
- Edit Name: setEditingFlowName handler moved
- Save Name: submitFlowName handler moved
- Cancel: setEditingFlowName(false) handler moved
- API Endpoint: onAPIDialogClick handler moved
- Save: onSaveChatflowClick handler moved
- Settings: setSettingsOpen handler moved

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

Summary of Changes

Hello @fuleinist, 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 improves the application's accessibility by refactoring how click events are handled for several key UI buttons. By relocating onClick handlers from non-interactive Avatar elements to their interactive ButtonBase parents, the changes ensure that these buttons are properly recognized and operable by keyboard navigation and screen readers, thereby enhancing inclusivity and adherence to accessibility standards.

Highlights

  • Accessibility Improvement: Moved onClick handlers from Avatar components to their parent ButtonBase components for seven specific UI elements to enhance keyboard and screen reader accessibility.
  • Enhanced User Experience: Enabled keyboard navigation (Tab to focus, Enter/Space to activate) for previously inaccessible buttons, making the application more inclusive.
  • Compliance: Ensured better compliance with accessibility standards by correctly structuring interactive elements.
Changelog
  • packages/ui/src/views/canvas/CanvasHeader.jsx
    • Moved the onClick handler for the 'Back' navigation button from Avatar to ButtonBase.
    • Moved the onClick handler for the 'Edit Name' button from Avatar to ButtonBase.
    • Moved the onClick handler for the 'Save Name' button from Avatar to ButtonBase.
    • Moved the onClick handler for the 'Cancel' button from Avatar to ButtonBase.
    • Moved the onClick handler for the 'API Endpoint' button from Avatar to ButtonBase.
    • Moved the onClick handler for the 'Save' button from Avatar to ButtonBase.
    • Moved the onClick handler for the 'Settings' button from Avatar to ButtonBase.
Activity
  • No review activity or comments have been recorded for this pull request yet.
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 improves accessibility by moving all onClick handlers from Avatar components to their parent ButtonBase components in CanvasHeader.jsx. This is a great change that makes the UI more inclusive for keyboard and screen reader users. The implementation is straightforward and effective. I have one suggestion to improve code readability by extracting a more complex inline function into a named handler, which aligns with general best practices for clean code.

Comment on lines +256 to +262
<ButtonBase title='Back' sx={{ borderRadius: '50%' }} 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 maintainability, consider extracting this multi-line inline function into a named function within the CanvasHeader component. For example, you could define const handleBack = () => { ... } before the return statement and then use onClick={handleBack}. This keeps the JSX clean and separates logic from presentation.

References
  1. Prioritize code readability and understandability over conciseness. A series of simple, chained operations can be preferable to a single, more complex one (e.g., a complex regex with a replacer function) if it improves understandability and reduces the potential for future errors.

@fuleinist fuleinist closed this Feb 25, 2026
@fuleinist
Copy link
Author

Thank you for the review @gemini-code-assist!

Regarding the suggestion about extracting inline functions into named handlers - that's a valid point for code readability. However, in this case, these handlers are simple one-liners that call existing methods already defined in the component (like setEditingFlowName, onAPIDialogClick, etc.). Extracting them to separate functions would add unnecessary verbosity without significant benefit.

The handlers moved are:

  • () => setEditingFlowName(true) - calls existing method
  • () => setEditingFlowName(false) - calls existing method
  • () => submitFlowName() - calls existing method
  • () => navigate(-1) or navigate('/', { replace: true }) - calls react-router methods
  • etc.

These are already properly named at the component level. The key fix was moving the onClick from the child Avatar (non-interactive) to the parent ButtonBase (semantic button element).

Would you like me to refactor further, or is this acceptable for merging?

@gemini-code-assist
Copy link
Contributor

Thank you for the detailed explanation, @fuleinist! I appreciate you taking the time to clarify your reasoning.

You're absolutely right that for simple one-liner calls to existing methods, extracting them into separate named functions can indeed add unnecessary verbosity without a significant gain in readability or maintainability. The primary goal of this pull request, which is to improve accessibility by correctly placing the onClick handlers on the ButtonBase components, has been successfully achieved.

Given the simplicity of these handlers, the current implementation is perfectly acceptable for merging. Great work on enhancing the accessibility of these UI elements!

@fuleinist fuleinist reopened this Feb 25, 2026
@HenryHengZJ
Copy link
Contributor

how is this different from #5821

@fuleinist
Copy link
Author

Good catch @HenryHengZJ! You're right - this PR is essentially duplicating #5821. I should have checked for existing PRs before creating this one.

I'll close this PR as a duplicate of #5821, which addresses the same accessibility fix. Thanks for pointing this out!

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.

3 participants