@hashicorp/design-system-components 0.12.12 → 0.12.13

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @hashicorp/design-system-components
2
2
 
3
+ ## 0.12.13
4
+
5
+ ### Patch Changes
6
+
7
+ - [#461](https://github.com/hashicorp/design-system/pull/461) [`71465b37`](https://github.com/hashicorp/design-system/commit/71465b377b5ff4f47eca2bcfb096df9f082b23cb) Thanks [@alex-ju](https://github.com/alex-ju)! - Fix computation error on disclosure (take 2)
8
+
3
9
  ## 0.12.12
4
10
 
5
11
  ### Patch Changes
@@ -1,11 +1,11 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { tracked } from '@glimmer/tracking';
3
3
  import { action } from '@ember/object';
4
+ import { schedule } from '@ember/runloop';
4
5
 
5
6
  export default class HdsDisclosureComponent extends Component {
6
7
  @tracked isOpen; // notice: if in the future we need to add a "@isOpen" prop to control the status from outside (eg to have the Disclosure opened on render) just add "this.args.isOpen" here to initalize the variable
7
8
  @tracked toggleRef;
8
- @tracked isToggleClicked;
9
9
 
10
10
  @action
11
11
  didInsert(element) {
@@ -18,12 +18,7 @@ export default class HdsDisclosureComponent extends Component {
18
18
  if (!this.toggleRef) {
19
19
  this.toggleRef = event.currentTarget;
20
20
  }
21
- // we're using an explicit conditional statement to toggle the `isOpen` property to avoid a backtracking rerender assertion caused by setting and getting a `@tracked` property in the same computation
22
- if (this.isOpen) {
23
- this.isOpen = false;
24
- } else {
25
- this.isOpen = true;
26
- }
21
+ this.isOpen = !this.isOpen;
27
22
  // we explicitly apply a focus state to the toggle element to overcome a bug in WebKit (see b8abfcf)
28
23
  this.toggleRef.focus();
29
24
  }
@@ -48,12 +43,13 @@ export default class HdsDisclosureComponent extends Component {
48
43
 
49
44
  @action
50
45
  close() {
51
- if (this.isOpen) {
46
+ // we schedule this afterRender to avoid an error in tests caused by updating `isOpen` multiple times in the same computation
47
+ schedule('afterRender', () => {
52
48
  this.isOpen = false;
53
- }
54
- // we call the "onClose" callback if it exists (and is a function)
55
- if (this.args.onClose && typeof this.args.onClose === 'function') {
56
- this.args.onClose();
57
- }
49
+ // we call the "onClose" callback if it exists (and is a function)
50
+ if (this.args.onClose && typeof this.args.onClose === 'function') {
51
+ this.args.onClose();
52
+ }
53
+ });
58
54
  }
59
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hashicorp/design-system-components",
3
- "version": "0.12.12",
3
+ "version": "0.12.13",
4
4
  "description": "HashiCorp Design System Components",
5
5
  "keywords": [
6
6
  "hashicorp",