-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core/tooltip): prevent focusin event call showTooltip (#1221)
- Loading branch information
1 parent
846edc4
commit 555a5a3
Showing
5 changed files
with
171 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@siemens/ix": patch | ||
--- | ||
|
||
fix(core/tooltip): prevent focusin event call showTooltip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
packages/core/src/components/tooltip/tooltip-controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Siemens AG | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import { OverlayController } from '../utils/overlay'; | ||
|
||
class TooltipController extends OverlayController {} | ||
|
||
export const tooltipController = new TooltipController(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Siemens AG | ||
* | ||
* SPDX-License-Identifier: MIT | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
import { IxComponent } from '../utils/internal'; | ||
|
||
export interface IxOverlayComponent extends IxComponent { | ||
isPresent(): boolean; | ||
|
||
willPresent?(): boolean; | ||
willDismiss?(): boolean; | ||
|
||
present(): void; | ||
dismiss(): void; | ||
} | ||
|
||
export class OverlayController { | ||
overlays: Set<IxOverlayComponent> = new Set(); | ||
|
||
connected(instance: IxOverlayComponent): void { | ||
this.overlays.add(instance); | ||
} | ||
|
||
disconnected(instance: IxOverlayComponent): void { | ||
this.overlays.delete(instance); | ||
} | ||
|
||
present(instance: IxOverlayComponent): void { | ||
if (instance.willPresent && !instance.willPresent()) { | ||
return; | ||
} | ||
this.dismissOthers(instance); | ||
instance.present(); | ||
} | ||
|
||
dismiss(instance: IxOverlayComponent): void { | ||
if (instance.willDismiss && !instance.willDismiss()) { | ||
return; | ||
} | ||
instance.dismiss(); | ||
} | ||
|
||
private dismissOthers(instance: IxOverlayComponent): void { | ||
this.overlays.forEach((overlay) => { | ||
if (overlay !== instance) { | ||
this.dismiss(overlay); | ||
} | ||
}); | ||
} | ||
} |