Skip to content

fix: prevent addon stylesheet links from being removed during CSS live reload#23892

Merged
mshabarov merged 1 commit intomainfrom
fix/23880-jar_resources_live_reload
Mar 20, 2026
Merged

fix: prevent addon stylesheet links from being removed during CSS live reload#23892
mshabarov merged 1 commit intomainfrom
fix/23880-jar_resources_live_reload

Conversation

@mcollovati
Copy link
Collaborator

During CSS live reload, PublicResourcesLiveUpdater pushed null content for addon stylesheets not found in local source roots, and removeOldLinks() in vaadin-dev-tools used substring matching (.includes()) which could incorrectly remove unrelated <link> tags.

Server-side changes:

  • Add jar-resources folder as a watched source root in DevModeHandlerManagerImpl so addon CSS changes are detected
  • Skip pushing null updates for stylesheets that exist on the classpath (e.g. from addon JARs) in PublicResourcesLiveUpdater
  • Use ResourceProvider to check classpath existence before deciding to remove a stylesheet
  • Strip frontend/ prefix in PublicStyleSheetBundler when resolving addon stylesheets against jar-resources roots, since TaskCopyFrontendFiles removes that prefix during copy

Client-side change:

  • Replace .includes(path) with path-suffix matching in removeOldLinks() to only remove links whose href ends with '/' + path or exactly equals path, after stripping query strings and fragments

Fixes #23880

…e reload

During CSS live reload, `PublicResourcesLiveUpdater` pushed null content
for addon stylesheets not found in local source roots, and
`removeOldLinks()` in vaadin-dev-tools used substring matching
(`.includes()`) which could incorrectly remove unrelated `<link>` tags.

Server-side changes:
- Add jar-resources folder as a watched source root in
  `DevModeHandlerManagerImpl` so addon CSS changes are detected
- Skip pushing null updates for stylesheets that exist on the classpath
  (e.g. from addon JARs) in `PublicResourcesLiveUpdater`
- Use `ResourceProvider` to check classpath existence before deciding
  to remove a stylesheet
- Strip `frontend/` prefix in `PublicStyleSheetBundler` when resolving
  addon stylesheets against jar-resources roots, since
  `TaskCopyFrontendFiles` removes that prefix during copy

Client-side change:
- Replace `.includes(path)` with path-suffix matching in
  `removeOldLinks()` to only remove links whose href ends with
  `'/' + path` or exactly equals `path`, after stripping query
  strings and fragments

Fixes #23880
@mcollovati mcollovati added target/25.0 Cherry-pick to 25.0 branch target/25.1 labels Mar 16, 2026
@sonarqubecloud
Copy link

@github-actions
Copy link

github-actions bot commented Mar 16, 2026

Test Results

 1 384 files   1 384 suites   1h 27m 11s ⏱️
 9 912 tests  9 841 ✅ 71 💤 0 ❌
10 385 runs  10 305 ✅ 80 💤 0 ❌

Results for commit 315327f.

♻️ This comment has been updated with latest results.

@mshabarov mshabarov self-requested a review March 16, 2026 12:33
@mshabarov mshabarov merged commit f842b1f into main Mar 20, 2026
50 of 52 checks passed
@mshabarov mshabarov deleted the fix/23880-jar_resources_live_reload branch March 20, 2026 11:15
vaadin-bot pushed a commit that referenced this pull request Mar 20, 2026
…e reload (#23892)

During CSS live reload, `PublicResourcesLiveUpdater` pushed null content
for addon stylesheets not found in local source roots, and
`removeOldLinks()` in vaadin-dev-tools used substring matching
(`.includes()`) which could incorrectly remove unrelated `<link>` tags.

Server-side changes:
- Add jar-resources folder as a watched source root in
  `DevModeHandlerManagerImpl` so addon CSS changes are detected
- Skip pushing null updates for stylesheets that exist on the classpath
  (e.g. from addon JARs) in `PublicResourcesLiveUpdater`
- Use `ResourceProvider` to check classpath existence before deciding
  to remove a stylesheet
- Strip `frontend/` prefix in `PublicStyleSheetBundler` when resolving
  addon stylesheets against jar-resources roots, since
  `TaskCopyFrontendFiles` removes that prefix during copy

Client-side change:
- Replace `.includes(path)` with path-suffix matching in
  `removeOldLinks()` to only remove links whose href ends with
  `'/' + path` or exactly equals `path`, after stripping query
  strings and fragments

Fixes #23880
@vaadin-bot
Copy link
Collaborator

Hi @mcollovati and @mshabarov, when i performed cherry-pick to this commit to 25.0, i have encountered the following issue. Can you take a look and pick it manually?
Error Message:
Error: Command failed: git cherry-pick f842b1f
error: could not apply f842b1f... fix: prevent addon stylesheet links from being removed during CSS live reload (#23892)
hint: After resolving the conflicts, mark them with
hint: "git add/rm ", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".

vaadin-bot added a commit that referenced this pull request Mar 20, 2026
…e reload (#23892) (#23960)

During CSS live reload, `PublicResourcesLiveUpdater` pushed null content
for addon stylesheets not found in local source roots, and
`removeOldLinks()` in vaadin-dev-tools used substring matching
(`.includes()`) which could incorrectly remove unrelated `<link>` tags.

Server-side changes:
- Add jar-resources folder as a watched source root in
  `DevModeHandlerManagerImpl` so addon CSS changes are detected
- Skip pushing null updates for stylesheets that exist on the classpath
  (e.g. from addon JARs) in `PublicResourcesLiveUpdater`
- Use `ResourceProvider` to check classpath existence before deciding
  to remove a stylesheet
- Strip `frontend/` prefix in `PublicStyleSheetBundler` when resolving
  addon stylesheets against jar-resources roots, since
  `TaskCopyFrontendFiles` removes that prefix during copy

Client-side change:
- Replace `.includes(path)` with path-suffix matching in
  `removeOldLinks()` to only remove links whose href ends with
  `'/' + path` or exactly equals `path`, after stripping query
  strings and fragments

Fixes #23880

Co-authored-by: Marco Collovati <marco@vaadin.com>
mcollovati added a commit that referenced this pull request Mar 24, 2026
…e reload (#23892)

During CSS live reload, `PublicResourcesLiveUpdater` pushed null content
for addon stylesheets not found in local source roots, and
`removeOldLinks()` in vaadin-dev-tools used substring matching
(`.includes()`) which could incorrectly remove unrelated `<link>` tags.

Server-side changes:
- Add jar-resources folder as a watched source root in
  `DevModeHandlerManagerImpl` so addon CSS changes are detected
- Skip pushing null updates for stylesheets that exist on the classpath
  (e.g. from addon JARs) in `PublicResourcesLiveUpdater`
- Use `ResourceProvider` to check classpath existence before deciding
  to remove a stylesheet
- Strip `frontend/` prefix in `PublicStyleSheetBundler` when resolving
  addon stylesheets against jar-resources roots, since
  `TaskCopyFrontendFiles` removes that prefix during copy

Client-side change:
- Replace `.includes(path)` with path-suffix matching in
  `removeOldLinks()` to only remove links whose href ends with
  `'/' + path` or exactly equals `path`, after stripping query
  strings and fragments

Fixes #23880
mshabarov pushed a commit that referenced this pull request Mar 25, 2026
…e reload (#23892) (CP: 25.0) (#23981)

* fix: prevent addon stylesheet links from being removed during CSS live reload (#23892)

During CSS live reload, `PublicResourcesLiveUpdater` pushed null content
for addon stylesheets not found in local source roots, and
`removeOldLinks()` in vaadin-dev-tools used substring matching
(`.includes()`) which could incorrectly remove unrelated `<link>` tags.

Server-side changes:
- Add jar-resources folder as a watched source root in
  `DevModeHandlerManagerImpl` so addon CSS changes are detected
- Skip pushing null updates for stylesheets that exist on the classpath
  (e.g. from addon JARs) in `PublicResourcesLiveUpdater`
- Use `ResourceProvider` to check classpath existence before deciding
  to remove a stylesheet
- Strip `frontend/` prefix in `PublicStyleSheetBundler` when resolving
  addon stylesheets against jar-resources roots, since
  `TaskCopyFrontendFiles` removes that prefix during copy

Client-side change:
- Replace `.includes(path)` with path-suffix matching in
  `removeOldLinks()` to only remove links whose href ends with
  `'/' + path` or exactly equals `path`, after stripping query
  strings and fragments

Fixes #23880

* fix test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Style hotswap breaks "external" / addon styles

3 participants