Skip to content

Conversation

@amandac628
Copy link
Collaborator

@amandac628 amandac628 commented Nov 25, 2025

…g for on click on option

📖 Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

  • Added clear button for single and multi select of combobox.
  • Updated click handler to prevent 'padding' issues
  • Kept the menu open when on select/unselect until user clicks out
  • Only handles the input focus when user closes menu within combobox
    • to address the double clicking needed to unfocus the combobox
image

Fixes # (issue)

✏️ Type of change

Please delete options that are not relevant.
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

🧪 How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

✅ Checklist:

  • My code follows the SGDS style guidelines and naming conventions
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules

@amandac628 amandac628 requested review from clukhei and th-94 November 25, 2025 09:05
@amandac628 amandac628 marked this pull request as draft November 25, 2025 09:07
@amandac628 amandac628 marked this pull request as ready for review December 4, 2025 10:26
@amandac628 amandac628 requested review from clukhei and th-94 December 4, 2025 10:27
Comment on lines 145 to 150
private _handleClickOutOfElement = (e: MouseEvent) => {
if (!this.menuIsOpen) return;
if (!e.composedPath().includes(this)) {
this.hideMenu();
this.hideMenu(true);
}
};
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added the boolean here, so that when we listen to the 'sgds-hide' event, we can differentiate when it's called.


option.addEventListener("keydown", (evt: KeyboardEvent) => {
if (evt.key === "Enter") {
this.close = "outside";
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This line is to prevent the menu from closing, as i don't want to touch the dropdown-list-element keyboard implementation

if (this.multiSelect) {
if (!this.selectedItems.some(i => i.value === foundItem.value)) {
this.selectedItems = [...this.selectedItems, foundItem];
setTimeout(() => (this.displayValue = ""));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tested, when removing this seems to have not much impact. can anyone recall why we need to set this to empty string?

@clukhei
Copy link
Collaborator

clukhei commented Dec 8, 2025

  1. Clicking checkbox area not updating menu items
    https://github.com/user-attachments/assets/a23c2e53-c13c-441d-ac36-5aad9f47dbd9

  2. For form reset, if i cancel away the initial value and press reset the correct behaviour should
    be to restore to the iinitial values on the first time i click reset button. No error should be shown..
    https://github.com/user-attachments/assets/98c77618-7176-44c5-928a-dfb18490548e

hmm but im not sure why point 1 is sometimes ok, sometimes not ok

 into 474-combobox-add-in-clear-selection-button-in-dropdown-menu
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.

4 participants