Skip to content

Conversation

@Shyam-123pandey
Copy link

@Shyam-123pandey Shyam-123pandey commented Jan 7, 2026

This commit removes comment-only and whitespace-only changes that were
introduced during drafting.
This is improved version of things, like previously i only changed in textarea.js but for more improvement some changes in validation also.
No functional or behavioral changes are intended.
#11736

Copilot AI review requested due to automatic review settings January 7, 2026 07:16
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR claims to remove comment-only and whitespace-only changes, but actually introduces significant new functionality alongside formatting fixes. The main additions include pattern validation for textarea fields and automatic bridge/tunnel tagging when changing feature layers.

Key changes:

  • Added pattern validation functionality to textarea fields with visual feedback
  • Implemented automatic bridge/tunnel tagging when adjusting layer values in crossing ways validation
  • Fixed indentation and comment formatting issues

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.

File Description
modules/validations/crossing_ways.js Fixed indentation, modernized array method, refactored layer logic, and added new bridge/tunnel tagging behavior based on layer changes
modules/ui/fields/textarea.js Added pattern validation function with visual feedback, updated event handlers to support validation, and added new imports
css/30_highways.css Fixed malformed comment syntax and added whitespace for readability

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +830 to +841
// Apply bridge/tunnel ONLY to allowed linear features
if (featureType && allowsBridge(featureType) && higherOrLower === 'higher') {
tags.bridge = 'yes';
delete tags.tunnel;
} else if (featureType && allowsTunnel(featureType) && higherOrLower === 'lower') {
tags.tunnel = 'yes';
delete tags.bridge;
} else {
// Buildings or unsupported features
delete tags.bridge;
delete tags.tunnel;
}
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description states "No functional or behavioral changes are intended", but this change introduces significant new functionality. The code now automatically adds or removes bridge/tunnel tags based on the layer direction and feature type, which is a behavioral change that should be:

  1. Explicitly documented in the PR description
  2. Covered by tests
  3. Reviewed as a feature addition, not as a refactoring

Consider splitting this into a separate PR with appropriate tests and documentation.

Copilot uses AI. Check for mistakes.
try {
const regex = new RegExp(field.pattern);
isInvalid = !regex.test(value);
} catch {
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The catch block silently ignores all errors without any logging or handling. If the regex construction fails due to an invalid pattern, this should at least be logged for debugging purposes. Consider logging the error or adding a comment explaining why silent failure is acceptable here.

Suggested change
} catch {
} catch (err) {
// Log invalid regex patterns for debugging while preserving existing behavior
/* eslint-disable no-console */
console.error('uiFieldTextarea: invalid regex pattern for field.pattern', field.pattern, err);
/* eslint-enable no-console */

Copilot uses AI. Check for mistakes.
Comment on lines +830 to +841
// Apply bridge/tunnel ONLY to allowed linear features
if (featureType && allowsBridge(featureType) && higherOrLower === 'higher') {
tags.bridge = 'yes';
delete tags.tunnel;
} else if (featureType && allowsTunnel(featureType) && higherOrLower === 'lower') {
tags.tunnel = 'yes';
delete tags.bridge;
} else {
// Buildings or unsupported features
delete tags.bridge;
delete tags.tunnel;
}
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new logic that automatically adds bridge='yes' or tunnel='yes' tags when changing layers lacks test coverage. Given that test/spec/validations/crossing_ways.js exists and tests layer-related behavior, this new functionality should be tested to ensure:

  1. Bridge tags are correctly added when moving to higher layers
  2. Tunnel tags are correctly added when moving to lower layers
  3. Tags are correctly removed for unsupported feature types
  4. Bridge and tunnel tags are mutually exclusive

Copilot uses AI. Check for mistakes.
_lengthIndicator.update(tags[field.key]);
}

updatePatternValidation();
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line contains trailing whitespace. Remove the trailing spaces for code cleanliness.

Suggested change
updatePatternValidation();
updatePatternValidation();

Copilot uses AI. Check for mistakes.
Comment on lines +75 to +93
const value = utilGetSetValue(input).trim();

if (!value) {
wrap.selectAll('.form-field-pattern-info').remove();
return;
}

let isInvalid = false;
try {
const regex = new RegExp(field.pattern);
isInvalid = !regex.test(value);
} catch {
return;
}

const info = wrap.selectAll('.form-field-pattern-info')
.data(isInvalid ? [0] : []);

const enter = info.enter()
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new function uses modern JavaScript variable declarations (const/let) while the rest of the file consistently uses var. For consistency with the existing codebase style, consider using var instead of const/let throughout this function, or update the entire file to use modern declarations in a separate refactoring PR.

Suggested change
const value = utilGetSetValue(input).trim();
if (!value) {
wrap.selectAll('.form-field-pattern-info').remove();
return;
}
let isInvalid = false;
try {
const regex = new RegExp(field.pattern);
isInvalid = !regex.test(value);
} catch {
return;
}
const info = wrap.selectAll('.form-field-pattern-info')
.data(isInvalid ? [0] : []);
const enter = info.enter()
var value = utilGetSetValue(input).trim();
if (!value) {
wrap.selectAll('.form-field-pattern-info').remove();
return;
}
var isInvalid = false;
try {
var regex = new RegExp(field.pattern);
isInvalid = !regex.test(value);
} catch {
return;
}
var info = wrap.selectAll('.form-field-pattern-info')
.data(isInvalid ? [0] : []);
var enter = info.enter()

Copilot uses AI. Check for mistakes.
Comment on lines +822 to +824
var layer = Number(tags.layer);
if (!isNaN(layer)) {
layer += (higherOrLower === 'higher' ? 1 : -1);
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code now uses Number(tags.layer) without checking if tags.layer exists first. If tags.layer is undefined, Number(undefined) returns NaN, which is handled by the isNaN check. However, this is less explicit than the original code which checked tags.layer && before calling Number. Consider adding a comment explaining this intentional change, or revert to the more explicit pattern for clarity.

Suggested change
var layer = Number(tags.layer);
if (!isNaN(layer)) {
layer += (higherOrLower === 'higher' ? 1 : -1);
var rawLayer = tags.layer;
var layer;
if (rawLayer && !isNaN(Number(rawLayer))) {
layer = Number(rawLayer) + (higherOrLower === 'higher' ? 1 : -1);

Copilot uses AI. Check for mistakes.
Comment on lines +72 to +107
function updatePatternValidation() {
if (!field.pattern || !wrap || wrap.empty()) return;

const value = utilGetSetValue(input).trim();

if (!value) {
wrap.selectAll('.form-field-pattern-info').remove();
return;
}

let isInvalid = false;
try {
const regex = new RegExp(field.pattern);
isInvalid = !regex.test(value);
} catch {
return;
}

const info = wrap.selectAll('.form-field-pattern-info')
.data(isInvalid ? [0] : []);

const enter = info.enter()
.append('div')
.attr('class', 'form-field-pattern-info');

enter
.append('span')
.call(svgIcon('#iD-icon-info'));

enter
.append('span')
.attr('class', 'form-field-pattern-info-text')
.text(t('inspector.invalid_format'));

info.exit().remove();
}
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description states "No functional or behavioral changes are intended", but this change introduces new pattern validation functionality for textarea fields. This is a significant feature addition that:

  1. Should be explicitly documented in the PR description
  2. Requires test coverage
  3. Should be reviewed as a feature addition, not as a refactoring

Consider splitting this into a separate PR with appropriate tests and documentation explaining when and how pattern validation works.

Copilot uses AI. Check for mistakes.

info.exit().remove();
}
// ============================
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment line appears to be a separator or section marker but doesn't provide meaningful information. Consider removing it or replacing it with a more descriptive comment explaining what follows (e.g., "// Public API methods").

Suggested change
// ============================
// Public API methods

Copilot uses AI. Check for mistakes.
};
}
}

Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line contains trailing whitespace. Remove the trailing spaces for code cleanliness.

Copilot uses AI. Check for mistakes.
@k-yle k-yle linked an issue Jan 7, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tag this as higher does nothing it seems to the user

1 participant