Compare commits

..

2 Commits

Author SHA1 Message Date
Harel M
c168e65d86 Fix editor incorrect scroll (#1525)
## Launch Checklist

- Fixes #1524

The problem is that the editor at the end of the layer editor view is
forcing some scrolling due to a different bug that was solved.
- #1492 which was solved in PR: #1501

The previous fix was in oder to solve issues in the code editor which
has all the style in it, and a search-and-replace operation is used to
change the content, so there was a need to introduce the previous fix.
The current solution is to scroll the view only for the code editor
using a react prop, which is `false` by default.

 - [x] Briefly describe the changes in this PR.
 - [x] Link to related issues.
 - [ ] Write tests for all new functionality.
 - [x] Add an entry to `CHANGELOG.md` under the `## main` section.
2025-12-03 11:39:10 +00:00
dependabot[bot]
8095b0d641 chore(deps): Bump @maplibre/maplibre-gl-inspect from 1.8.0 to 1.8.1 (#1553)
Bumps
[@maplibre/maplibre-gl-inspect](https://github.com/maplibre/maplibre-gl-inspect)
from 1.8.0 to 1.8.1.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/maplibre/maplibre-gl-inspect/releases"><code>@​maplibre/maplibre-gl-inspect</code>'s
releases</a>.</em></p>
<blockquote>
<h2>v1.8.1</h2>
<h3><a
href="https://github.com/maplibre/maplibre-gl-inspect/compare/v1.8.0...v1.8.1">1.8.1</a>
(2025-12-02)</h3>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="fd257413d6"><code>fd25741</code></a>
Bump version to 1.8.1 (<a
href="https://redirect.github.com/maplibre/maplibre-gl-inspect/issues/336">#336</a>)</li>
<li><a
href="17f6906a12"><code>17f6906</code></a>
Add bump version action (<a
href="https://redirect.github.com/maplibre/maplibre-gl-inspect/issues/335">#335</a>)</li>
<li><a
href="582eb0e1ae"><code>582eb0e</code></a>
Improve error message for missing vector layers</li>
<li><a
href="8e4906811c"><code>8e49068</code></a>
bigfix: properly infer the layer IDs from the style in fallback; uniqify
the ...</li>
<li><a
href="e8070caafc"><code>e8070ca</code></a>
Bump typedoc from 0.28.14 to 0.28.15 (<a
href="https://redirect.github.com/maplibre/maplibre-gl-inspect/issues/333">#333</a>)</li>
<li><a
href="6b8dce5e34"><code>6b8dce5</code></a>
Bump rollup-plugin-dts from 6.2.3 to 6.3.0 (<a
href="https://redirect.github.com/maplibre/maplibre-gl-inspect/issues/332">#332</a>)</li>
<li><a
href="81a19a1300"><code>81a19a1</code></a>
Bump typescript-eslint from 8.47.0 to 8.48.0 (<a
href="https://redirect.github.com/maplibre/maplibre-gl-inspect/issues/331">#331</a>)</li>
<li><a
href="051f714cd5"><code>051f714</code></a>
Bump rollup from 4.53.1 to 4.53.3 (<a
href="https://redirect.github.com/maplibre/maplibre-gl-inspect/issues/329">#329</a>)</li>
<li><a
href="3f912912e2"><code>3f91291</code></a>
Bump typescript-eslint from 8.46.3 to 8.47.0 (<a
href="https://redirect.github.com/maplibre/maplibre-gl-inspect/issues/330">#330</a>)</li>
<li><a
href="006e6b0d25"><code>006e6b0</code></a>
Bump maplibre-gl from 5.12.0 to 5.13.0 (<a
href="https://redirect.github.com/maplibre/maplibre-gl-inspect/issues/328">#328</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/maplibre/maplibre-gl-inspect/compare/v1.8.0...v1.8.1">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=@maplibre/maplibre-gl-inspect&package-manager=npm_and_yarn&previous-version=1.8.0&new-version=1.8.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-03 11:27:21 +00:00
6 changed files with 27 additions and 14 deletions

View File

@@ -26,6 +26,7 @@
- Fix issue with missing bottom error panel
- Fixed headers in left panes (Layers list and Layer editor) to remain visible when scrolling
- Fix error when using a source from localhost
- Fix an issue with scrolling when using the code editor
- _...Add new stuff here..._
## 3.0.0

View File

@@ -178,11 +178,11 @@ describe("modals", () => {
});
it("sprite object", () => {
when.setTextInJsonEditor(JSON.stringify([{id: "1", url: "2"}]));
when.setTextInJsonEditor(JSON.stringify([{ id: "1", url: "2" }]));
when.click("modal:settings.name");
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
sprite: [{ id: "1", url: "2"}],
sprite: [{ id: "1", url: "2" }],
});
});
@@ -342,8 +342,8 @@ describe("modals", () => {
});
it("add variable", () => {
when.click("global-state-add-variable");
when.wait(100);
when.click("global-state-add-variable");
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
state: { key1: { default: "value" } },
});
@@ -373,6 +373,7 @@ describe("modals", () => {
it("edit variable key", () => {
when.click("global-state-add-variable");
when.wait(100);
when.setValue("global-state-variable-key:0", "mykey");
when.typeKeys("{enter}");
when.wait(100);
@@ -383,6 +384,7 @@ describe("modals", () => {
it("edit variable value", () => {
when.click("global-state-add-variable");
when.wait(100);
when.setValue("global-state-variable-value:0", "myvalue");
when.typeKeys("{enter}");
when.wait(100);

8
package-lock.json generated
View File

@@ -19,7 +19,7 @@
"@dnd-kit/utilities": "^3.2.2",
"@mapbox/mapbox-gl-rtl-text": "^0.3.0",
"@maplibre/maplibre-gl-geocoder": "^1.9.1",
"@maplibre/maplibre-gl-inspect": "^1.8.0",
"@maplibre/maplibre-gl-inspect": "^1.8.1",
"@maplibre/maplibre-gl-style-spec": "^24.3.1",
"array-move": "^4.0.0",
"buffer": "^6.0.3",
@@ -2156,9 +2156,9 @@
}
},
"node_modules/@maplibre/maplibre-gl-inspect": {
"version": "1.8.0",
"resolved": "https://registry.npmjs.org/@maplibre/maplibre-gl-inspect/-/maplibre-gl-inspect-1.8.0.tgz",
"integrity": "sha512-uRufOTPg4tXDYc+W8fVHbvSN2m2ThPy1ASmL7wvnQMObOKu738bA7M1fwZeCNsqDERb2nT4tW6bi4EYzUjGv2g==",
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/@maplibre/maplibre-gl-inspect/-/maplibre-gl-inspect-1.8.1.tgz",
"integrity": "sha512-Wh+MpaksNNWwA6wyH94D0gNzJdd4fFeImO2nqLDO1AxdF4NAML+HTrLE3XjWmVSPOZ7dDi/0IAZ8dc4IakyT0g==",
"license": "BSD-3-Clause",
"dependencies": {
"lodash.isequal": "^4.5.0",

View File

@@ -36,7 +36,7 @@
"@dnd-kit/utilities": "^3.2.2",
"@mapbox/mapbox-gl-rtl-text": "^0.3.0",
"@maplibre/maplibre-gl-geocoder": "^1.9.1",
"@maplibre/maplibre-gl-inspect": "^1.8.0",
"@maplibre/maplibre-gl-inspect": "^1.8.1",
"@maplibre/maplibre-gl-style-spec": "^24.3.1",
"array-move": "^4.0.0",
"buffer": "^6.0.3",

View File

@@ -19,6 +19,7 @@ const CodeEditorInternal: React.FC<CodeEditorProps> = (props) => {
value={props.value}
onChange={props.onChange}
className={"maputnik-code-editor"}
withScroll={true}
/>;
</>;
};

View File

@@ -7,6 +7,7 @@ import stringifyPretty from "json-stringify-pretty-compact";
import {createEditor} from "../libs/codemirror-editor-factory";
import type { StylePropertySpecification } from "maplibre-gl";
import type { TransactionSpec } from "@codemirror/state";
export type InputJsonProps = {
value: object
@@ -16,6 +17,11 @@ export type InputJsonProps = {
onBlur?(...args: unknown[]): unknown
lintType: "layer" | "style" | "expression" | "json"
spec?: StylePropertySpecification | undefined
/**
* When setting this and using search and replace, the editor will scroll to the selected text
* Use this only when the editor is the only element in the page.
*/
withScroll?: boolean
};
type InputJsonInternalProps = InputJsonProps & WithTranslation;
@@ -28,6 +34,7 @@ class InputJsonInternal extends React.Component<InputJsonInternalProps, InputJso
static defaultProps = {
onFocus: () => {},
onBlur: () => {},
withScroll: false
};
_view: EditorView | undefined;
_el: HTMLDivElement | null = null;
@@ -74,16 +81,18 @@ class InputJsonInternal extends React.Component<InputJsonInternalProps, InputJso
componentDidUpdate(prevProps: InputJsonProps) {
if (!this.state.isEditing && prevProps.value !== this.props.value) {
this._cancelNextChange = true;
const currentSelection = this._view!.state.selection;
this._view!.dispatch({
const transactionSpec: TransactionSpec = {
changes: {
from: 0,
to: this._view!.state.doc.length,
insert: this.getPrettyJson(this.props.value)
},
selection: currentSelection,
scrollIntoView: true
});
}
};
if (this.props.withScroll) {
transactionSpec.selection = this._view!.state.selection;
transactionSpec.scrollIntoView = true;
}
this._view!.dispatch(transactionSpec);
}
}