@ordergroove/offers 2.41.0 → 2.42.0

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ordergroove/offers",
3
- "version": "2.41.0",
3
+ "version": "2.42.0",
4
4
  "description": "offer state component",
5
5
  "author": "Eugenio Lattanzio <eugenio63@gmail.com>",
6
6
  "homepage": "https://github.com/ordergroove/plush-toys#readme",
@@ -46,8 +46,8 @@
46
46
  "throttle-debounce": "^2.1.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@ordergroove/offers-templates": "^0.9.6",
49
+ "@ordergroove/offers-templates": "^0.9.7",
50
50
  "@types/lodash.memoize": "^4.1.9"
51
51
  },
52
- "gitHead": "24e315047abbe0e265409f1f5265e3d9fd462672"
52
+ "gitHead": "7acd066ed3c38e3067555de011a9e3c2bd2b4439"
53
53
  }
@@ -152,7 +152,8 @@ export class Tooltip extends LitElement {
152
152
  border-left: solid var(--og-tooltip-background, #ececec) 10px;
153
153
  }
154
154
 
155
- .tooltip:hover .content {
155
+ .tooltip:hover .content,
156
+ .trigger:focus + .content {
156
157
  opacity: 1;
157
158
  width: 200px;
158
159
  pointer-events: auto;
@@ -163,11 +164,12 @@ export class Tooltip extends LitElement {
163
164
 
164
165
  connectedCallback() {
165
166
  super.connectedCallback();
166
- this.showTooltip = this.showTooltip.bind(this);
167
- this.addEventListener('mouseenter', this.showTooltip);
167
+ this.recalculatePosition = this.recalculatePosition.bind(this);
168
+ this.addEventListener('mouseenter', this.recalculatePosition);
169
+ this.addEventListener('focusin', this.recalculatePosition);
168
170
  }
169
171
 
170
- showTooltip() {
172
+ recalculatePosition() {
171
173
  const trigger = this.shadowRoot.querySelector('.trigger');
172
174
  const triggerRect = trigger.getBoundingClientRect();
173
175
  const content = this.shadowRoot.querySelector('.content');
@@ -180,14 +182,14 @@ export class Tooltip extends LitElement {
180
182
 
181
183
  disconnectedCallback() {
182
184
  super.disconnectedCallback();
183
- this.removeEventListener('mouseenter', this.showTooltip);
184
- this.removeEventListener('mouseout', this.hideTooltip);
185
+ this.removeEventListener('mouseenter', this.recalculatePosition);
186
+ this.removeEventListener('focusin', this.recalculatePosition);
185
187
  }
186
188
 
187
189
  render() {
188
190
  return html`
189
191
  <span class="tooltip">
190
- <span class="trigger">
192
+ <span class="trigger" tabindex="0">
191
193
  <slot name="trigger">${this.trigger}</slot>
192
194
  </span>
193
195
  <div class="content ${this.placement || 'bottom'}">
@@ -36,7 +36,7 @@ describe('Tooltip', () => {
36
36
  });
37
37
  }
38
38
 
39
- element.showTooltip();
39
+ element.recalculatePosition();
40
40
  Object.keys(expectedStyles).forEach(key => expect(contentDiv.style[key]).toEqual(expectedStyles[key]));
41
41
  };
42
42