@playkit-js/hotspots 3.2.18 → 3.2.19-canary.0-3defb45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -63,6 +63,8 @@ const MINIMAL_FONT_SIZE = 10;
|
|
|
63
63
|
export default class Hotspot extends Component<Props, State> {
|
|
64
64
|
static defaultProps = defaultProps;
|
|
65
65
|
|
|
66
|
+
hotspotRef: HTMLDivElement | null = null;
|
|
67
|
+
|
|
66
68
|
state = {
|
|
67
69
|
disableClick: true,
|
|
68
70
|
isReady: false
|
|
@@ -72,21 +74,29 @@ export default class Hotspot extends Component<Props, State> {
|
|
|
72
74
|
const {hotspot, dispatcher} = this.props;
|
|
73
75
|
|
|
74
76
|
if (!hotspot || !hotspot.onClick) {
|
|
75
|
-
this.setState({
|
|
76
|
-
|
|
77
|
+
this.setState({ isReady: true }, () => {
|
|
78
|
+
this.setFocus();
|
|
77
79
|
});
|
|
78
80
|
return;
|
|
79
81
|
}
|
|
80
82
|
|
|
81
|
-
this.setState(
|
|
82
|
-
isReady: true,
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
this.setState(
|
|
84
|
+
{ isReady: true, disableClick: !this.isClickable() },
|
|
85
|
+
() => {
|
|
86
|
+
this.setFocus();
|
|
87
|
+
}
|
|
88
|
+
);
|
|
85
89
|
|
|
86
90
|
const {id, label} = hotspot;
|
|
87
91
|
dispatcher(HotspotsEvents.HOTSPOT_DISPLAYED, {id, label});
|
|
88
92
|
}
|
|
89
93
|
|
|
94
|
+
setFocus = () => {
|
|
95
|
+
if (this.hotspotRef) {
|
|
96
|
+
setTimeout(() => this.hotspotRef?.focus(), 0);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
90
100
|
isClickable = (): boolean => {
|
|
91
101
|
const {
|
|
92
102
|
hotspot: {onClick}
|
|
@@ -193,8 +203,8 @@ export default class Hotspot extends Component<Props, State> {
|
|
|
193
203
|
};
|
|
194
204
|
|
|
195
205
|
return (
|
|
196
|
-
<A11yWrapper onClick={this.handleClick}>
|
|
197
|
-
<div tabIndex={0} aria-label={label} aria-disabled={disableClick} style={containerStyles} data-testid="hotspots_hotspot">
|
|
206
|
+
<A11yWrapper onClick={this.handleClick} aria-live="polite">
|
|
207
|
+
<div ref={(ref) => (this.hotspotRef = ref)} tabIndex={0} role="button" aria-label={label} aria-disabled={disableClick} style={containerStyles} data-testid="hotspots_hotspot">
|
|
198
208
|
<div style={buttonStyles}>{label}</div>
|
|
199
209
|
</div>
|
|
200
210
|
</A11yWrapper>
|