Skip to content

Commit 1383b37

Browse files
authored
fix(useStyleSheet): scope component name to ui5wc runtime (#6395)
1 parent a5eb344 commit 1383b37

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed
Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: 'Release - Snapshot'
22

3-
on:
4-
workflow_dispatch
3+
on: workflow_dispatch
54

65
jobs:
76
test:
@@ -25,7 +24,7 @@ jobs:
2524
fetch-depth: 0
2625

2726
- name: Setup Node.js environment
28-
uses: actions/[email protected].4
27+
uses: actions/[email protected].3
2928
with:
3029
node-version-file: '.nvmrc'
3130
registry-url: 'https://registry.npmjs.org'
@@ -34,34 +33,23 @@ jobs:
3433
run: |
3534
npm install -g npm
3635
yarn install
36+
yarn build
3737
38-
- name: version
38+
- name: publish
3939
run: |
4040
git config user.email ${{ secrets.BOT_GIT_EMAIL }}
4141
git config user.name ${{ secrets.BOT_GIT_USERNAME }}
4242
4343
git_hash=$(git rev-parse --short "$GITHUB_SHA")
4444
current_branch=$(node -p -e "'${{ github.ref }}'.replace('refs/heads/', '')")
45-
echo "current_branch=${current_branch}" >> "$GITHUB_ENV"
4645
47-
${GITHUB_WORKSPACE}/node_modules/.bin/lerna version "0.0.0-${git_hash}" \
46+
${GITHUB_WORKSPACE}/node_modules/.bin/lerna publish "0.0.0-${git_hash}" \
4847
--exact \
4948
--no-push \
5049
--no-git-tag-version \
50+
--pre-dist-tag dev \
5151
--allow-branch ${current_branch}
52-
env:
53-
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
54-
NPM_CONFIG_PROVENANCE: true
5552
56-
- name: build
57-
run: yarn build
58-
59-
- name: publish to npm
60-
run: |
61-
${GITHUB_WORKSPACE}/node_modules/.bin/lerna publish from-git \
62-
--pre-dist-tag dev \
63-
--allow-branch ${{ env.current_branch }}
6453
env:
65-
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
6654
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
6755
NPM_CONFIG_PROVENANCE: true

packages/base/src/hooks/useStylesheet.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import type { StyleDataCSP } from '@ui5/webcomponents-base/dist/ManagedStyles.js';
44
import { createOrUpdateStyle, removeStyle } from '@ui5/webcomponents-base/dist/ManagedStyles.js';
5+
import { getCurrentRuntimeIndex } from '@ui5/webcomponents-base/dist/Runtimes.js';
56
import { useSyncExternalStore } from 'use-sync-external-store/shim/index.js';
67
import { StyleStore } from '../stores/StyleStore.js';
78
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect.js';
@@ -18,9 +19,10 @@ export function useStylesheet(styles: StyleDataCSP, componentName: string, optio
1819
);
1920

2021
useIsomorphicLayoutEffect(() => {
22+
const scopedComponentName = `${componentName}-${getCurrentRuntimeIndex()}`;
2123
const shouldInject = options?.alwaysInject || !staticCssInjected;
2224
if (shouldInject) {
23-
createOrUpdateStyle(styles, 'data-ui5wcr-component', componentName);
25+
createOrUpdateStyle(styles, 'data-ui5wcr-component', scopedComponentName);
2426
StyleStore.mountComponent(componentName);
2527
}
2628

@@ -29,7 +31,7 @@ export function useStylesheet(styles: StyleDataCSP, componentName: string, optio
2931
StyleStore.unmountComponent(componentName);
3032
const numberOfMountedComponents = componentsMap.get(componentName)!;
3133
if (numberOfMountedComponents <= 0) {
32-
removeStyle('data-ui5wcr-component', componentName);
34+
removeStyle('data-ui5wcr-component', scopedComponentName);
3335
}
3436
}
3537
};

0 commit comments

Comments
 (0)