@stackoverflow/stacks 1.0.1 → 1.1.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.
@@ -278,21 +278,33 @@ export class PopoverController extends BasePopoverController {
278
278
  private boundHideOnEscapePress!: any;
279
279
 
280
280
  /**
281
- * Toggles optional classes in addition to BasePopoverController.shown
281
+ * Toggles optional classes and accessibility attributes in addition to BasePopoverController.shown
282
282
  */
283
- protected shown(dispatcher: Element|null = null) {
283
+ protected override shown(dispatcher: Element|null = null) {
284
284
  this.toggleOptionalClasses(true);
285
+ this.toggleAccessibilityAttributes(true);
285
286
  super.shown(dispatcher);
286
287
  }
287
288
 
288
289
  /**
289
- * Toggles optional classes in addition to BasePopoverController.hidden
290
+ * Toggles optional classes and accessibility attributes in addition to BasePopoverController.hidden
290
291
  */
291
- protected hidden(dispatcher: Element|null = null) {
292
+ protected override hidden(dispatcher: Element|null = null) {
292
293
  this.toggleOptionalClasses(false);
294
+ this.toggleAccessibilityAttributes(false);
293
295
  super.hidden(dispatcher);
294
296
  }
295
297
 
298
+
299
+ /**
300
+ * Initializes accessibility attributes in addition to BasePopoverController.connect
301
+ */
302
+ public override connect(): void {
303
+ super.connect();
304
+
305
+ this.toggleAccessibilityAttributes();
306
+ }
307
+
296
308
  /**
297
309
  * Binds global events to the document for hiding popovers on user interaction
298
310
  */
@@ -307,7 +319,7 @@ export class PopoverController extends BasePopoverController {
307
319
  /**
308
320
  * Unbinds global events to the document for hiding popovers on user interaction
309
321
  */
310
- protected unbindDocumentEvents() {
322
+ protected unbindDocumentEvents() {
311
323
  document.removeEventListener("mousedown", this.boundHideOnOutsideClick);
312
324
  document.removeEventListener("keyup", this.boundHideOnEscapePress);
313
325
  }
@@ -357,6 +369,14 @@ export class PopoverController extends BasePopoverController {
357
369
  cl.toggle(cls, show);
358
370
  });
359
371
  }
372
+
373
+ /**
374
+ * Toggles accessibility attributes based on whether the popover is shown or not
375
+ * @param {boolean=} show - A boolean indicating whether this is being triggered by a show or hide.
376
+ */
377
+ private toggleAccessibilityAttributes(show?: boolean) {
378
+ this.referenceElement.ariaExpanded = show?.toString() || this.referenceElement.ariaExpanded || 'false';
379
+ }
360
380
  }
361
381
 
362
382
  /**
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "git",
6
6
  "url": "https://github.com/StackExchange/Stacks.git"
7
7
  },
8
- "version": "1.0.1",
8
+ "version": "1.1.0",
9
9
  "files": [
10
10
  "dist",
11
11
  "lib"
@@ -30,41 +30,40 @@
30
30
  },
31
31
  "license": "MIT",
32
32
  "dependencies": {
33
- "@popperjs/core": "^2.11.4",
33
+ "@popperjs/core": "^2.11.5",
34
34
  "stimulus": "^2.0.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@11ty/eleventy": "^1.0.0",
37
+ "@11ty/eleventy": "^1.0.1",
38
38
  "@highlightjs/cdn-assets": "^11.5.1",
39
39
  "@stackoverflow/stacks-editor": "^0.4.2",
40
40
  "@stackoverflow/stacks-icons": "^2.27.0",
41
- "@typescript-eslint/eslint-plugin": "^5.18.0",
42
- "@typescript-eslint/parser": "^5.18.0",
41
+ "@typescript-eslint/eslint-plugin": "^5.22.0",
42
+ "@typescript-eslint/parser": "^5.22.0",
43
43
  "backstopjs": "^6.0.4",
44
44
  "concurrently": "^7.1.0",
45
45
  "css-loader": "^6.7.1",
46
46
  "cssnano": "^5.1.7",
47
47
  "docsearch.js": "^2.6.3",
48
- "eleventy-plugin-highlightjs": "^1.0.0",
48
+ "eleventy-plugin-highlightjs": "^1.1.0",
49
49
  "eleventy-plugin-nesting-toc": "^1.3.0",
50
- "eslint": "^8.13.0",
50
+ "eslint": "^8.15.0",
51
51
  "eslint-config-prettier": "^8.5.0",
52
52
  "eslint-plugin-no-unsanitized": "^4.0.1",
53
- "grunt-concurrent": "^3.0.0",
54
53
  "jquery": "^3.6.0",
55
54
  "less-loader": "^10.2.0",
56
55
  "list.js": "^2.3.1",
57
- "markdown-it": "^12.3.2",
56
+ "markdown-it": "^13.0.1",
58
57
  "mini-css-extract-plugin": "^2.6.0",
59
58
  "postcss-less": "^6.0.0",
60
59
  "postcss-loader": "^6.2.1",
61
60
  "prettier": "^2.6.2",
62
- "stylelint": "^14.6.1",
61
+ "stylelint": "^14.8.2",
63
62
  "stylelint-config-recommended": "^7.0.0",
64
63
  "stylelint-config-standard": "^25.0.0",
65
64
  "terser-webpack-plugin": "^5.3.1",
66
- "ts-loader": "^9.2.8",
67
- "typescript": "^4.6.3",
65
+ "ts-loader": "^9.3.0",
66
+ "typescript": "^4.6.4",
68
67
  "webpack": "^5.72.0",
69
68
  "webpack-cli": "^4.9.2",
70
69
  "webpack-merge": "^5.8.0"