-
Notifications
You must be signed in to change notification settings - Fork 2
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
Issue 51432: LKSM: special character in sample names is not working well on various pages #1658
Changes from 8 commits
32034bd
3eba0e3
576d2e9
764b032
0bc0cf3
8c19692
2f1d4de
0dd7129
1940ff1
466f5d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -291,8 +291,12 @@ async function getLookupValueDescriptors( | |||||
return descriptorMap; | ||||||
} | ||||||
|
||||||
function lookupValidationError(value: string | number | boolean): CellMessage { | ||||||
return { message: `Could not find ${value}` }; | ||||||
function lookupValidationError(value: string | number | boolean, fromPaste?: boolean): CellMessage { | ||||||
let suffix = ''; | ||||||
if (fromPaste && typeof value === 'string' && value.toString().indexOf(',') > -1) { | ||||||
suffix = '. Please make sure values that contains comma(,) are properly quoted.'; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
return { message: `Could not find ${value}${suffix}` }; | ||||||
} | ||||||
|
||||||
async function getLookupDisplayValue(column: QueryColumn, value: any, containerPath: string): Promise<MessageAndValue> { | ||||||
|
@@ -455,16 +459,15 @@ export function addColumns( | |||||
if (insertFieldKey && leftColIndex < editorModel.orderedColumns.size - 1) { | ||||||
let readOnlyEnded = false; | ||||||
editorModel.orderedColumns.forEach((fieldKey, ind) => { | ||||||
if (ind <= leftColIndex || readOnlyEnded) | ||||||
return; | ||||||
if (!editorModel.columnMap.get(fieldKey).readOnly) | ||||||
readOnlyEnded = true; | ||||||
else | ||||||
altInsertFieldKey = fieldKey; | ||||||
if (ind <= leftColIndex || readOnlyEnded) return; | ||||||
if (!editorModel.columnMap.get(fieldKey).readOnly) readOnlyEnded = true; | ||||||
else altInsertFieldKey = fieldKey; | ||||||
}); | ||||||
|
||||||
if (altInsertFieldKey) | ||||||
leftColIndex = editorModel.orderedColumns.findIndex(column => Utils.caseInsensitiveEquals(column, altInsertFieldKey)); | ||||||
leftColIndex = editorModel.orderedColumns.findIndex(column => | ||||||
Utils.caseInsensitiveEquals(column, altInsertFieldKey) | ||||||
); | ||||||
} | ||||||
|
||||||
const editorModelIndex = leftColIndex + 1; | ||||||
|
@@ -940,7 +943,7 @@ export function parsePastedLookup( | |||||
.slice(0, 4) | ||||||
.map(u => '"' + u + '"') | ||||||
.join(', '); | ||||||
message = lookupValidationError(valueStr); | ||||||
message = lookupValidationError(valueStr, true); | ||||||
} | ||||||
|
||||||
return { | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -781,6 +781,7 @@ function addEdges( | |
} | ||
} | ||
|
||
const FULLWIDTH_AMPERSAND = '&'; // U+FF06, use as alt display for & so vis-network won't error out | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So odd that this is even a thing. |
||
function createVisNode( | ||
node: LineageNode, | ||
id: string, | ||
|
@@ -791,11 +792,28 @@ function createVisNode( | |
// show the alternate icon image color if this node is the seed or has been selected | ||
const { image, imageBackup, imageSelected, imageShape } = node.iconProps; | ||
|
||
let nodeLabel = node.name; | ||
// Issue 51432: LKSM: special character in sample names result in client side exception: SyntaxError: unterminated character class | ||
// vis-network does special processing for labels that evaluates to true for `/&/.test()` | ||
if (nodeLabel?.indexOf('&') > -1) { | ||
// for labels that starts with '&', the entire label is replaced with '<' by vis | ||
if (nodeLabel.startsWith('&')) { | ||
nodeLabel = nodeLabel.replace('&', FULLWIDTH_AMPERSAND); | ||
} | ||
|
||
try { | ||
new RegExp(nodeLabel); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably not a huge deal, but since regular expressions and exception throwing are relatively expensive, perhaps it would be more efficient to always do the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was hoping to preserve the original labels as much as possible. The hope is that there aren't many that contains & to trigger this code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably true that there aren't many &-names, or we would have heard more about this problem, and maybe the world of JavaScript is different in this regard than Java, but I still think it's more efficient (and targeted) to do the replacement without regex construction, especially since it seems like this RegExp construction could throw an error for other reasons than the &. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure that makes sense. Since user can't copy label from the vis canvas, it's no harm to do the replacement more aggressively. Updated to use replaceAll instead. |
||
} catch (error) { | ||
// vis-network is not able to tolerate the presence of '&' in certain strings due to Uncaught SyntaxError from `new RegExp()`. Encoding does not help. | ||
nodeLabel = nodeLabel.replaceAll('&', FULLWIDTH_AMPERSAND); | ||
} | ||
} | ||
|
||
return { | ||
kind: 'node', | ||
id, | ||
lineageNode: node, | ||
label: node.name, | ||
label: nodeLabel, | ||
level: level(depth, dir, false), | ||
title: getLineageNodeTitle(node, true), | ||
image: { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.