Skip to content

Commit

Permalink
improve click handling on touch devices by adding the touchend listen…
Browse files Browse the repository at this point in the history
…er to buttons
  • Loading branch information
stonko1994 committed Jan 16, 2025
1 parent ad91c9c commit c5b5d51
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/ts/components/buttons/Button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ export class Button<Config extends ButtonConfig> extends Component<Config> {
}).html(i18n.performLocalization(this.config.text)));

// Listen for the click event on the button element and trigger the corresponding event on the button component
buttonElement.on('click', (e) => {
buttonElement.on('click touchend', (e) => {
e.preventDefault();
e.stopPropagation();
this.onClickEvent();
});
Expand Down
3 changes: 2 additions & 1 deletion src/ts/components/settings/DynamicSettingsPanelItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ export class DynamicSettingsPanelItem extends SettingsPanelItem<DynamicSettingsP
const handleItemClick = () => {
this.displayItemsSubPage();
};
this.getDomElement().on('click', (e) => {
this.getDomElement().on('click touchend', (e) => {
e.preventDefault();
e.stopPropagation();
handleItemClick();
});
Expand Down
6 changes: 5 additions & 1 deletion src/ts/components/settings/SettingsPanelSelectOption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ export class SettingsPanelSelectOption extends SettingsPanelItem<SettingsPanelSe
const handleItemClick = () => {
this.settingComponent.selectItem(this.settingsValue);
};
this.getDomElement().on('click', () => handleItemClick());
this.getDomElement().on('click touchend', (e) => {
e.preventDefault();
e.stopPropagation();
handleItemClick();
});

// Initial state
handleSelectedOptionChanged();
Expand Down

0 comments on commit c5b5d51

Please sign in to comment.