Skip to content

Commit

Permalink
Fix item selection (click) in the context switcher (#2530)
Browse files Browse the repository at this point in the history
* Fix click event on combobox items
  • Loading branch information
elias-ba authored Sep 27, 2024
1 parent 2c1ddfe commit 442045c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ and this project adheres to

### Fixed

- Fix item selection (project / billing account) in the context switcher
[#2518](https://github.com/OpenFn/lightning/issues/2518)
- Export edge condition expressions as multiline in project spec
[#2521](https://github.com/OpenFn/lightning/issues/2521)

Expand All @@ -37,8 +39,8 @@ and this project adheres to

### Fixed

- Dataclip selector always shows that the dataclip is wiped even when the job wasn't run
[#2303](https://github.com/OpenFn/lightning/issues/2303)
- Dataclip selector always shows that the dataclip is wiped even when the job
wasn't run [#2303](https://github.com/OpenFn/lightning/issues/2303)
- Send run channel errors to sentry
[#2515](https://github.com/OpenFn/lightning/issues/2515)

Expand All @@ -57,7 +59,8 @@ and this project adheres to
[#2050](https://github.com/OpenFn/lightning/issues/2050)
- Add quotes when special YAML characters are present in the exported project
[#2446](https://github.com/OpenFn/lightning/issues/2446)
- In the AI Assistant, don't open the help page when clicking the Responsible AI Link [#2511](https://github.com/OpenFn/lightning/issues/2511)
- In the AI Assistant, don't open the help page when clicking the Responsible AI
Link [#2511](https://github.com/OpenFn/lightning/issues/2511)

## [v2.9.4] - 2024-09-16

Expand Down
22 changes: 15 additions & 7 deletions assets/js/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export const Combobox = {
this.toggleButton.addEventListener('click', () => this.toggleDropdown());

this.options.forEach((option, index) => {
option.addEventListener('click', () => this.selectOption(index));
option.addEventListener('click', () =>
this.selectOption(this.options.indexOf(option))
);
option.addEventListener('mouseenter', () => this.handleMouseEnter(index));
option.addEventListener('mousemove', () => this.handleMouseMove(index));
});
Expand Down Expand Up @@ -87,7 +89,11 @@ export const Combobox = {
case 'Enter':
event.preventDefault();
if (this.highlightedIndex !== -1) {
this.selectOption(this.highlightedIndex);
const visibleOptions = this.getVisibleOptions();
const selectedOptionIndex = this.options.indexOf(
visibleOptions[this.highlightedIndex]
);
this.selectOption(selectedOptionIndex);
}
break;
case 'Escape':
Expand Down Expand Up @@ -197,11 +203,13 @@ export const Combobox = {
},

selectOption(index) {
const visibleOptions = this.getVisibleOptions();
const selectedOption = visibleOptions[index];
this.input.value = selectedOption.textContent.trim();
this.hideDropdown();
this.navigateToItem(selectedOption.dataset.url);
const selectedOption = this.options[index];

if (selectedOption && selectedOption.style.display !== 'none') {
this.input.value = selectedOption.textContent.trim();
this.hideDropdown();
this.navigateToItem(selectedOption.dataset.url);
}
},

navigateToItem(url) {
Expand Down

0 comments on commit 442045c

Please sign in to comment.