Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(svg): set pointer-events as visible when fill/stroke color none in SSR mode & fix invalid transparent color issue #1076

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/svg/Painter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class SVGPainter implements PainterBase {
scope.willUpdate = opts.willUpdate;
scope.compress = opts.compress;
scope.emphasis = opts.emphasis;
scope.ssr = this._opts.ssr;

const children: SVGVNode[] = [];

Expand Down
2 changes: 2 additions & 0 deletions src/svg/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ export interface BrushScope {
* If compress the output string.
*/
compress?: boolean

ssr?: boolean
}

export function createBrushScope(zrId: string): BrushScope {
Expand Down
10 changes: 6 additions & 4 deletions src/svg/graphic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@ function setStyleAttrs(attrs: SVGVNodeAttrs, style: AllStyleOption, el: Path | T
else if (isFillStroke && isPattern(val)) {
setPattern(el, attrs, key, scope);
}
else if (isFillStroke && val === 'none') {
// When is none, it cannot be interacted when ssr
attrs[key] = 'transparent';
}
else {
attrs[key] = val;
}
if (isFillStroke && scope.ssr && val === 'none') {
// When is none, it cannot be interacted when ssr
// Setting `pointer-events` as `visible` to make it responding
// See also https://www.w3.org/TR/SVG/interact.html#PointerEventsProperty
attrs['pointer-events'] = 'visible';
}
}, style, el, false);

setShadow(el, attrs, scope);
Expand Down
Loading