Skip to content

Conversation

@andrew-polk
Copy link
Contributor

@andrew-polk andrew-polk commented Jan 6, 2026

This change is Reviewable

@andrew-polk andrew-polk force-pushed the BL15345_NavButtonFixes branch 2 times, most recently from e9255c0 to 3d2585d Compare January 7, 2026 00:06
Copy link
Contributor

@JohnThomson JohnThomson left a comment

Choose a reason for hiding this comment

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

@JohnThomson reviewed 5 files and all commit messages, and made 7 comments.
Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @andrew-polk).


src/BloomBrowserUI/react_components/LinkTargetChooser/URLEditor.tsx line 108 at r1 (raw file):

    function isExternalUrl(url: string): boolean {
        return /^(https?:)?\/\//i.test(url);
    }

Not quite sure which problem is being corrected here. It feels like a fairly drastic change...before we let C# handle any url not starting with /book, now we only let it handle https?: ones. I suppose it's unlikely we'd have any others, but a mailto: url could conceivably be wanted. Is there anything useful to say in a comment about why only http urls should be considered external?


src/BloomBrowserUI/bookEdit/js/CanvasElementContextControls.tsx line 1152 at r1 (raw file):

    if (
        !isNavigationButton(canvasElement) &&

I think it would be helpful to have a distinct comment here on why nav buttons don't do this...especially since having a link is the main reason for some kinds to exist. IIRC the reason is that it duplicates another command that is unique to nave buttons?


src/BloomBrowserUI/bookEdit/js/CanvasElementManager.ts line 4927 at r1 (raw file):

            undefined,
            undefined,
            keepInsideCanvas,

This is getting painful. Maybe it's time for finishAddingCanvasElement to take an object param, so you can include by name just the params you don't want a default for? I don't want to make a lot of extra work, so it's OK to say "too much trouble for now", but it seemed worth suggesting.


src/BloomBrowserUI/bookEdit/js/CanvasElementManager.ts line 5216 at r1 (raw file):

            { width: 120, height: 120 },
            doAfterElementCreated,
            true,

another example where it would be more readable as keepInsideCanvas: true


src/BloomBrowserUI/bookEdit/js/CanvasElementManager.ts line 5460 at r1 (raw file):

        // Technically, it only tries to move up and left if necessary to keep inside the canvas.
        if (keepInsideCanvas) {

Could we use all or part of the logic of ensureCanvasElementsIntersectParent() here? Or is it trying to do something distinctly different? I think it would be worth commenting, e.g., that here we want to make it entirely visible (if possible) whereas the other routine only wants to make sure it's at least partly visible.


src/BloomBrowserUI/bookEdit/js/CanvasElementManager.ts line 5463 at r1 (raw file):

            const bloomCanvas = bloomCanvasJQuery.get(0) as HTMLElement;
            const canvasSize = getExactClientSize(bloomCanvas);
            const elementWidth = canvasElement.clientWidth;

It should have a style.width and height, too...would we get any useful improvement in precision by using them?


src/BloomBrowserUI/bookEdit/js/CanvasElementManager.ts line 5465 at r1 (raw file):

            const elementWidth = canvasElement.clientWidth;
            const elementHeight = canvasElement.clientHeight;
            const currentLeft = CanvasElementManager.pxToNumber(

It's odd that we have elementWidth and elementHeight along with currentLeft and currentTop for variables that hold the current dimensions of the same element. I think it would be more readable if all four used one or the other. (I'd be inclined to use currentCeLeft etc.)

@andrew-polk andrew-polk force-pushed the BL15345_NavButtonFixes branch from 3d2585d to 24988aa Compare January 7, 2026 22:42
Copy link
Contributor Author

@andrew-polk andrew-polk left a comment

Choose a reason for hiding this comment

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

@andrew-polk made 7 comments.
Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @JohnThomson).


src/BloomBrowserUI/bookEdit/js/CanvasElementContextControls.tsx line 1152 at r1 (raw file):

Previously, JohnThomson (John Thomson) wrote…

I think it would be helpful to have a distinct comment here on why nav buttons don't do this...especially since having a link is the main reason for some kinds to exist. IIRC the reason is that it duplicates another command that is unique to nave buttons?

Done.


src/BloomBrowserUI/bookEdit/js/CanvasElementManager.ts line 4927 at r1 (raw file):

Previously, JohnThomson (John Thomson) wrote…

This is getting painful. Maybe it's time for finishAddingCanvasElement to take an object param, so you can include by name just the params you don't want a default for? I don't want to make a lot of extra work, so it's OK to say "too much trouble for now", but it seemed worth suggesting.

Done.


src/BloomBrowserUI/bookEdit/js/CanvasElementManager.ts line 5216 at r1 (raw file):

Previously, JohnThomson (John Thomson) wrote…

another example where it would be more readable as keepInsideCanvas: true

Done.


src/BloomBrowserUI/bookEdit/js/CanvasElementManager.ts line 5460 at r1 (raw file):

Previously, JohnThomson (John Thomson) wrote…

Could we use all or part of the logic of ensureCanvasElementsIntersectParent() here? Or is it trying to do something distinctly different? I think it would be worth commenting, e.g., that here we want to make it entirely visible (if possible) whereas the other routine only wants to make sure it's at least partly visible.

Done.


src/BloomBrowserUI/bookEdit/js/CanvasElementManager.ts line 5463 at r1 (raw file):

Previously, JohnThomson (John Thomson) wrote…

It should have a style.width and height, too...would we get any useful improvement in precision by using them?

copilot doesn't think it is an improvement; but it did decide that getExactClientSize was an improvement


src/BloomBrowserUI/bookEdit/js/CanvasElementManager.ts line 5465 at r1 (raw file):

Previously, JohnThomson (John Thomson) wrote…

It's odd that we have elementWidth and elementHeight along with currentLeft and currentTop for variables that hold the current dimensions of the same element. I think it would be more readable if all four used one or the other. (I'd be inclined to use currentCeLeft etc.)

Done.


src/BloomBrowserUI/react_components/LinkTargetChooser/URLEditor.tsx line 108 at r1 (raw file):

Previously, JohnThomson (John Thomson) wrote…

Not quite sure which problem is being corrected here. It feels like a fairly drastic change...before we let C# handle any url not starting with /book, now we only let it handle https?: ones. I suppose it's unlikely we'd have any others, but a mailto: url could conceivably be wanted. Is there anything useful to say in a comment about why only http urls should be considered external?

Added comment and changed the name.
The main fix is to not include links in the current book which start with #.

Copy link
Contributor

@JohnThomson JohnThomson left a comment

Choose a reason for hiding this comment

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

@JohnThomson reviewed 3 files and all commit messages, and resolved 7 discussions.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @andrew-polk).

@JohnThomson JohnThomson merged commit 5b3187a into Version6.3 Jan 8, 2026
2 checks passed
@JohnThomson JohnThomson deleted the BL15345_NavButtonFixes branch January 8, 2026 03:34
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.

3 participants