Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Arturo committed Apr 12, 2024
2 parents 48bef99 + bb7aabd commit 6992f89
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
State,
Watch,
Event,
EventEmitter,
VNode,
type EventEmitter,
type VNode,
} from '@stencil/core';
import classNames from 'classnames';
import statusNote from '../../utils/status-note';
Expand Down Expand Up @@ -228,6 +228,8 @@ function isInView(element: HTMLElement) {
);
}

let activeDropdown = null;

@Component({
tag: 'scale-dropdown-select',
styleUrl: 'dropdown-select.css',
Expand Down Expand Up @@ -461,7 +463,15 @@ export class DropdownSelect {
};

handleClick = () => {
// * This is a fix to prevent the dropdown from being opened when the user clicks on another combobox.
// ! https://github.com/telekom/scale/issues/2285
if (activeDropdown && activeDropdown !== this) {
activeDropdown.setOpen(false);
}

this.setOpen(!this.open);
activeDropdown = this;

const indexOfValue = readOptions(this.hostElement).findIndex(
({ value }) => value === this.value
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,9 @@ export class AppNavigationUserMenu {
}}
onKeyDown={(e) => {
if ([' ', 'Enter'].includes(e.key)) {
e.stopImmediatePropagation();
e.preventDefault();

if (item.onClick) {
e.stopImmediatePropagation();
e.preventDefault();
item.onClick(e);
}
this.hide();
Expand Down Expand Up @@ -128,16 +127,17 @@ export class AppNavigationUserMenu {
part="button"
onClick={(e) => {
if (item.onClick) {
e.stopImmediatePropagation();
e.preventDefault();
item.onClick(e);
}
this.hide();
}}
onKeyDown={(e) => {
if ([' ', 'Enter'].includes(e.key)) {
e.stopImmediatePropagation();
e.preventDefault();

if (item.onClick) {
e.stopImmediatePropagation();
e.preventDefault();
item.onClick(e);
}
this.hide();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
| `loginSettingsLabel` | `login-settings-label` | | `string` | `undefined` |
| `loginSettingsUrl` | `login-settings-url` | | `string` | `undefined` |
| `loginUrl` | `login-url` | | `string` | `undefined` |
| `logoutHandler` | `logout-handler` | | `string` | `undefined` |
| `logoutLabel` | `logout-label` | | `string` | `undefined` |
| `logoutUrl` | `logout-url` | | `string` | `undefined` |
| `registerHeadline` | `register-headline` | | `string` | `undefined` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export class TelekomProfileMenu {

@Prop() logoutLabel: string;
@Prop() logoutUrl?: string;
@Prop() logoutHandler?: string;

@State()
menuOpen = false;
Expand Down Expand Up @@ -161,6 +162,16 @@ export class TelekomProfileMenu {
);
}

buildLogoutButton() {
return {
type: 'button',
name: this.logoutLabel,
href: this.logoutUrl || LOGOUT_DEFAULT,
variant: 'secondary',
onClick: this.logoutHandler,
};
}

buildUserNavigation() {
const divider = [{ type: 'divider' }];

Expand All @@ -187,13 +198,6 @@ export class TelekomProfileMenu {
icon: 'service-settings',
};

const logout = {
type: 'button',
name: this.logoutLabel,
href: this.logoutUrl || LOGOUT_DEFAULT,
variant: 'secondary',
};

let menu = [];

menu = menu.concat(userInfo);
Expand All @@ -211,7 +215,7 @@ export class TelekomProfileMenu {
menu = menu.concat(divider);
}

menu = menu.concat(logout);
menu = menu.concat(this.buildLogoutButton());

return menu;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,11 @@ window.onload = () => {
email: '[email protected]',
});
profileMenu.serviceLinks = JSON.stringify(serviceLinks);
// optional: set a custom handler for clicks on logout button
profileMenu.logoutHandler = () => {
// ...
}
};
</script>
```
Expand Down Expand Up @@ -605,6 +610,11 @@ window.onload = () => {
email: '[email protected]',
});
profileMenu.serviceLinks = JSON.stringify(serviceLinks);
// optional: set a custom handler for clicks on logout button
profileMenu.logoutHandler = () => {
// ...
}
};
</script>
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@ This component is still in the beta phase. When testing it, keep in mind that it
- [Sidebar Navigation](?path=/usage/components-sidebar-navigation--standard)
- [Tab Navigation](?path=/usage/components-tab-navigation--text-icon)
- [Accordion](?path=/usage/components-accordion--standard)
- [Profile Menu](?path=/docs/components-telekom-profile-menu--logged-out)
- [Profile Menu](?path=/docs/components-telekom-brand-header-navigation--profile-menu-logged-out)
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ Diese Komponente befindet sich noch im Beta-Stadium. Wenn du sie testest, bedenk
- [Sidebar Navigation](?path=/usage/components-sidebar-navigation--standard)
- [Tab Navigation](?path=/usage/components-tab-navigation--text-icon)
- [Accordion](?path=/usage/components-accordion--standard)
- [Profile Menu](?path=/docs/components-telekom-profile-menu--logged-out)
- [Profile Menu](?path=/docs/components-telekom-brand-header-navigation--profile-menu-logged-out)

0 comments on commit 6992f89

Please sign in to comment.