@carbon/vue 3.0.30 → 3.0.31

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "@carbon/vue",
4
- "version": "3.0.29",
4
+ "version": "3.0.30",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/vue",
3
3
  "license": "Apache-2.0",
4
- "version": "3.0.30",
4
+ "version": "3.0.31",
5
5
  "description": "A collection of components for the Carbon Design System built using Vue.js",
6
6
  "packageManager": "yarn@3.2.0",
7
7
  "main": "dist/carbon-vue-3.umd.min.js",
@@ -77,7 +77,7 @@ const domTemplate = `
77
77
  const domCode = domTemplate.replace("v-bind='args'", '');
78
78
  const multipleTemplate = `
79
79
  <div>
80
- <cv-content-switcher aria-label='Choose content' v-bind='args' @selected="onSelected" id="star-wars">
80
+ <cv-content-switcher tabindex="0" aria-label='Choose content' v-bind='args' @selected="onSelected" id="star-wars">
81
81
  <cv-content-switcher-button parent-switcher="star-wars" owner-id="episode-1" :selected="selectedIndex === 0">Episode 1</cv-content-switcher-button>
82
82
  <cv-content-switcher-button parent-switcher="star-wars" owner-id="episode-2" :selected="selectedIndex === 1">Episode 2</cv-content-switcher-button>
83
83
  <cv-content-switcher-button parent-switcher="star-wars" :icon="iconSample" owner-id="episode-3" :selected="selectedIndex === 2">Episode 3</cv-content-switcher-button>
@@ -96,7 +96,7 @@ const multipleTemplate = `
96
96
  <p>Yoda</p>
97
97
  </cv-content-switcher-content>
98
98
  </section>
99
- <cv-content-switcher aria-label='Choose content' v-bind='args' @selected="onSelected" id="LotR">
99
+ <cv-content-switcher tabindex="1" aria-label='Choose content' v-bind='args' @selected="onSelected" id="LotR">
100
100
  <cv-content-switcher-button parent-switcher="LotR" owner-id="book-1" :selected="selectedIndex === 0">Book 1</cv-content-switcher-button>
101
101
  <cv-content-switcher-button parent-switcher="LotR" owner-id="book-2" :selected="selectedIndex === 1">Book 2</cv-content-switcher-button>
102
102
  <cv-content-switcher-button parent-switcher="LotR" :icon="iconSample" owner-id="book-3" :selected="selectedIndex === 2">Book 3</cv-content-switcher-button>
@@ -18,7 +18,7 @@
18
18
  import { carbonPrefix } from '../../global/settings';
19
19
  import { props as propsCvId, useCvId } from '../../use/cvId';
20
20
  import { useIsLight, props as propsTheme } from '../../use/cvTheme';
21
- import { onUnmounted, watch } from 'vue';
21
+ import { onUnmounted, watch, onMounted, nextTick } from 'vue';
22
22
  import store from './cvContentSwitcherStore';
23
23
 
24
24
  const emit = defineEmits(['selected']);
@@ -36,14 +36,26 @@ const cvId = useCvId(props, true);
36
36
  const isLight = useIsLight(props);
37
37
  store.addParent(cvId.value);
38
38
  store.setContentSelected('global', undefined);
39
+
40
+ // Check for initial selection after child components have set up
41
+ let hadInitialSelection = null;
42
+ onMounted(async () => {
43
+ // Use nextTick to ensure child components have mounted and set their initial state
44
+ await nextTick();
45
+ hadInitialSelection =
46
+ store.state[cvId.value]?.selected !== undefined &&
47
+ store.state[cvId.value]?.selected !== '';
48
+ });
49
+
39
50
  onUnmounted(() => {
40
51
  store.removeParent(cvId.value);
41
52
  });
53
+
42
54
  watch(
43
55
  () => store.state.global.latest,
44
56
  (val, prev) => {
45
57
  // if previous is not set, do not emit. This mimics the current v2 behaviour where the initial content does not generate an event
46
- if (prev) emit('selected', val);
58
+ if (prev || (val && hadInitialSelection === false)) emit('selected', val);
47
59
  }
48
60
  );
49
61
 
@@ -53,7 +65,9 @@ watch(
53
65
  val => {
54
66
  if (ourLatest !== val?.latest) {
55
67
  // if ourLatest is not set, do not emit. This mimics the current v2 behaviour where the initial content does not generate an event
56
- if (ourLatest) emit('selected', val?.latest);
68
+ // However, if there was no initial selection (selectedIndex=-1), we should emit on first click
69
+ if (ourLatest || (val?.latest && hadInitialSelection === false))
70
+ emit('selected', val?.latest);
57
71
  ourLatest = val?.latest;
58
72
  }
59
73
  },
@@ -13,8 +13,8 @@
13
13
  [`${carbonPrefix}--side-nav--ux`]: isChildOfHeader,
14
14
  },
15
15
  ]"
16
- :aria-hidden="!panelExpanded && !fixed ? 'true' : 'false'"
17
- :inert="!panelExpanded && !fixed"
16
+ :aria-hidden="isHidden ? 'true' : 'false'"
17
+ :inert="isHidden"
18
18
  @focusout="onFocusout"
19
19
  @mousedown="onMouseDown"
20
20
  @mouseenter="onHoverToggle(true)"
@@ -79,6 +79,9 @@ const panelExpanded = computed({
79
79
  data.dataExpanded = val;
80
80
  },
81
81
  });
82
+ const isHidden = computed(() => {
83
+ return !panelExpanded.value && !props.fixed && !props.rail;
84
+ });
82
85
  /**
83
86
  * @type {CvHeaderPanel}
84
87
  */