@@ -1443,6 +1443,48 @@ test('the justification follows the text across its anchor', async function({pag
14431443 expect ( errors ) . toEqual ( [ ] ) ;
14441444} ) ;
14451445
1446+ test ( 'an aligned label is dragged where it is drawn' , async function ( { page} ) {
1447+ // A label carrying a label-align is drawn with the anchor its alignment
1448+ // gives it, and the drag writes text-anchor=start against the correction the
1449+ // renderer applies. The preview used to write that stored value onto the
1450+ // rendered text, which drew a right-aligned label a full width right of the
1451+ // pointer and a centred one half a width -- and dropped it back into place
1452+ // on release, so the label appeared to jump left the moment it was let go.
1453+ var errors = collectPageErrors ( page ) ;
1454+ await loadFixture ( page , FIXTURE ) ;
1455+
1456+ await clickMap ( page , 0.45 , 0.45 ) ;
1457+ await writeLabel ( page , 'Winnemucca' ) ;
1458+ await disarmTool ( page ) ;
1459+ await clickLabel ( page , 0 ) ;
1460+ await setDragMode ( page , 'draggable' ) ;
1461+
1462+ for ( var align of [ 'right' , 'center' ] ) {
1463+ await page . locator ( '.text-style-panel .label-align-buttons [data-align="' +
1464+ align + '"]' ) . click ( ) ;
1465+ await page . waitForTimeout ( 200 ) ;
1466+ await hoverNothing ( page ) ;
1467+ var before = await getLabelBox ( page , 0 ) ;
1468+ var from = await getGlyphPoint ( page , 0 , 0.5 ) ;
1469+
1470+ await page . mouse . move ( from . x , from . y ) ;
1471+ await page . waitForTimeout ( 80 ) ;
1472+ await page . mouse . down ( ) ;
1473+ await page . mouse . move ( from . x + 60 , from . y - 30 , { steps : 8 } ) ;
1474+ // mid-drag: the text is under the pointer, not a width away from it
1475+ var dragging = await getLabelBox ( page , 0 ) ;
1476+ expect ( Math . abs ( dragging . x - ( before . x + 60 ) ) ) . toBeLessThan ( 2 ) ;
1477+
1478+ await page . mouse . up ( ) ;
1479+ await page . waitForTimeout ( 250 ) ;
1480+ // and the command's redraw leaves it where the drag showed it
1481+ var after = await getLabelBox ( page , 0 ) ;
1482+ expect ( Math . abs ( after . x - dragging . x ) ) . toBeLessThan ( 2 ) ;
1483+ expect ( ( await getLabelLayer ( page ) ) . records [ 0 ] [ 'label-align' ] ) . toBe ( align ) ;
1484+ }
1485+ expect ( errors ) . toEqual ( [ ] ) ;
1486+ } ) ;
1487+
14461488test ( 'the drag mode is the tool\'s and not the label\'s' , async function ( { page} ) {
14471489 // Nothing in the record says which segment is lit: a label with a position
14481490 // can be dragged or not, and one that has been dragged stays dragged when
0 commit comments