Skip to content

Initial column alignment is not applied in the WYSIWYG table widget #485

Closed

Description

@uNyanda
  • Date: 2026-07-25
  • Type: Bug
  • Severity: Minor

Environment

  • OS: Linux
  • WM: Niri
  • Compositor: Wayland
  • Software version: 2.18.0

Description

When changing the alignment of a newly created column in the WYSIWYG table widget, the selected alignment is not applied the first time it is chosen.

The same alignment option must be selected a second time before the column alignment is updated.

This occurs both after creating a new table and after adding new columns to an existing table.

Steps to reproduce

New table

  1. Create a new table using the /table slash-command.
  2. Move the cursor into any table cell.
  3. Press m to open the table context menu.
  4. Type align to filter the available actions.
  5. Select any alignment option (Left, Centre, or Right).
  6. Observe that the alignment is not applied.
  7. Select the same alignment option again.
  8. Observe that the alignment option is now applied.

Existing table

  1. Add a new column to an existing table.
  2. Move the cursor into a cell in the newly created column.
  3. Press m to open the table context menu.
  4. Type align to filter the available actions.
  5. Select any alignment option.
  6. Observe that the alignment is not applied until the same option is selected a second time.

Expected Behaviour

The selected column alignment should be applied immediately after it is chosen.

Actual Behaviour

The first alignment change for a newly created column is ignored. The same alignment option must be selected a second time before it takes effect.

Additional Notes

This issue appears to affect only newly created columns. Once the initial alignment has been applied, subsequent alignment changes for that column work as expected.

Activity

  1. adibhanna commented on Jul 27, 2026

    @adibhanna
    Contributor

    I haven't been able to reproduce this yet, so before guessing at a fix I'd rather show you exactly what I tested and ask for one detail.

    I drove the real packaged app through four variants, checking both the markdown on disk and the rendered widget DOM after a single selection:

    Scenario First selection applied?
    Existing table, existing column, clicked the item ✅ | :-: | --- |
    New column added via the menu, clicked the item ✅ --:
    New column, m → typed align → Enter ✅ :--
    Fresh /table table, m → typed align → Enter ✅ :-------

    In each case the <td> picked up align="left" / "center" too, so it wasn't just the markdown moving. Selecting the same option a second time removes the alignment — that's the deliberate toggle in the menu (choosing the alignment a column already has clears it back to none).

    In fairness I should say I briefly thought I'd reproduced it: my probe was reading the align attribute off the inner cell div when the widget sets it on the parent <td>. That was my mistake, not the app's.

    The one behaviour that does look like your report. A column with no explicit alignment is none, and none renders identically to left, since browsers left-align by default. So on a newly created column or a fresh table:

    1. Choose Align left → the markdown becomes :---, but nothing visibly changes.
    2. Choose it again → toggles back to none, and again nothing visibly changes.

    That would read exactly as "the first one was ignored", and it is specific to new columns — which matches your note that it only affects newly created ones. It doesn't explain Centre or Right, both of which visibly change on the first selection here.

    So the detail that would settle it: right after the first selection that appears to do nothing, what does the table's markdown look like — specifically, did the delimiter row change from | --- | to | :--- |?

    • If it did change, this is the "none looks like left" perception issue, and the fix is on our side to make the state legible (the menu already shows a ✓ on the active alignment; a fresh column showing none of them may be the real gap).
    • If it did not change, there's a genuine difference in your environment I can chase — a short screen recording, or the table's markdown before and after, would give me the fixture to work from.

    Unrelated bug I found while testing this, which may matter to you since your tables carry width markers: with a <!-- zen:cols=273,227 --> line present, any table menu action drops it, so persisted column widths are silently lost.

    before   | A | B |
             | --- | --- |
             | 1 | 2 |
             <!-- zen:cols=273,227 -->
    
    after    |  A  | B   |
             | :-: | --- |
             |  1  | 2   |          ← marker gone
    

    That's separate from this issue and I've left it alone for now; say the word and I'll file it.

  2. adibhanna commented on Jul 27, 2026

    @adibhanna
    Contributor

    Update: I still can't reproduce your exact report, but I found two real defects behind the symptom and both are fixed in v2.19.0 (195930a). I'm leaving this open until you can confirm on that build, since I can't honestly claim to have caught your bug.

    1. The alignment entries were a hidden toggle. Choosing the alignment a column already had cleared it back to none. Put that together with the thing I flagged in my last comment — a column with no alignment renders identically to a left-aligned one — and it produces your report exactly:

    • Fresh column, choose Align left → the markdown becomes :---, nothing looks different.
    • Choose it again → it silently reverts to ---, and again nothing looks different.

    The three entries are now a ticked radio group with a fourth, Align default:

    fresh column:       Align left | Align center | Align right | Align default ✓
    after Align left:   Align left ✓ | Align center | Align right | Align default
    

    So the state is visible before you choose, choosing an alignment only ever sets it, and clearing is a deliberate pick rather than a side effect of choosing twice.

    2. A table edit could be dropped silently. Committing a table action looks the table up in the syntax tree; when no Table node was found it just returned, discarding the edit with no feedback. Markdown parsing is incremental, so a table that was created or restructured moments earlier can still be outside the parsed tree. That is precisely a "that did nothing — do it again and it works" bug, and its likelihood depends on machine speed and document size rather than on anything visible, which fits a report that doesn't reproduce here. It now falls back to reading the table block out of the document instead of dropping the action.

    What I couldn't reproduce, for the record. Driving the packaged app, the first selection applied every single time: a fresh /table table, keystrokes 60 ms apart (the pace of real typing rather than my earlier deliberate probing), and a 4,000-paragraph note to starve the parser. In each case | --- | became | :------- | on the first choice.

    Could you re-test on 2.19.0 when it's out? If the alignment still needs two selections there, then it's defect 3 and I'd like:

    • the table's markdown immediately after the first selection — specifically whether the delimiter row changed from | --- | to | :--- |, and
    • a short screen recording if that's easy, since your compositor is the one variable I can't reproduce.

    If it behaves, I'll close this with a note about which of the two fixes was responsible.

    Unrelated: the column-widths bug I mentioned last time (any table menu action dropping a <!-- zen:cols=… --> marker) is fixed and ships in the same release.

  3. uNyanda commented on Jul 28, 2026

    @uNyanda
    ContributorAuthor

    @adibhanna, I tested again on v2.19.0 and I can still reproduce the issue.

    I've attached a short screen recording showing the behaviour. The recording shows:

    • creating a new table,
    • selecting a column alignment,
    • the first selection having no effect,
    • and the second selection applying the alignment.
    Image
  4. adibhanna commented on Jul 30, 2026

    @adibhanna
    Contributor

    Found it, fixed it, and this time I watched the fix work in the running app on your exact sequence. Your recording is what cracked it: the ingredient my earlier repro attempts were missing was typing in a cell right before opening the menu. Your clip types this, then m, then filters to Align center; frame by frame, the note's character count jumps at the exact moment the menu opens, and that jump is the whole bug.

    What actually happens: opening the menu moves focus out of the table widget. If you just typed in a cell, that focus-out commits your edit. The commit rebuilds the table widget, and the menu you are looking at still belongs to the old, now-detached widget. When you pick an action, its commit tried to locate the table through that dead widget and died in a silent early-return. Nothing in 2.19.0's fallback could help because the bail happened before the fallback ran. The second pick worked because nothing was dirty anymore, so no rebuild happened. It hits fresh tables and new columns hardest because a fresh table's first commit also writes the column-widths marker, making a rebuild all but guaranteed. And it never depended on your compositor: just on whether you typed before pressing m, which you did and I did not.

    The fix, in 2.20.0: the menu records where its table lives in the document the moment it opens, and if its widget has been rebuilt out from under it, the action commits against the current document at that position instead. Both menu entry points (keyboard m and right-click) are covered, and a commit that genuinely cannot find its table now logs a warning instead of discarding your action in silence, which is how this bug survived two rounds of fixing.

    Verified end to end in the real app: your recording's sequence, first selection, delimiter goes | --- | to | :------: | in the file on disk. Thank you for the persistence and especially for the recording; three rounds is a lot to ask of a reporter, and it genuinely took your clip to see it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions