[GH-ISSUE #951] Grid fixed column/row size goes to bottom right #699

Closed
opened 2026-03-04 01:07:06 +03:00 by kerem · 1 comment
Owner

Originally created by @jvalkeal on GitHub (Feb 23, 2024).
Original GitHub issue: https://github.com/rivo/tview/issues/951

I'm asking because docs don't explicitly mention anything about any column/row not taking remaining space but does mention a lot about top-left logic.

If I write existing grid demo as:

package main

import (
	"github.com/rivo/tview"
)

func main() {
	newPrimitive := func(text string) tview.Primitive {
		return tview.NewTextView().
			SetTextAlign(tview.AlignCenter).
			SetText(text)
	}

	grid := tview.NewGrid().
		SetRows(1).
		SetColumns(1).
		SetBorders(false).
		AddItem(newPrimitive("X"), 0, 0, 1, 1, 0, 0, false)

	if err := tview.NewApplication().SetRoot(grid, true).EnableMouse(true).Run(); err != nil {
		panic(err)
	}
}

X is always placed in a bottom-right corner.

This looks something like:

+---------+
|         |
|         |
|        X|
+---------+

Do I misunderstood grig logic as I'm kinda expecting X to be in a top-left corner like:

+---------+
|X        |
|         |
|         |
+---------+
Originally created by @jvalkeal on GitHub (Feb 23, 2024). Original GitHub issue: https://github.com/rivo/tview/issues/951 I'm asking because docs don't explicitly mention anything about any column/row not taking remaining space but does mention a lot about top-left logic. If I write existing grid demo as: ``` package main import ( "github.com/rivo/tview" ) func main() { newPrimitive := func(text string) tview.Primitive { return tview.NewTextView(). SetTextAlign(tview.AlignCenter). SetText(text) } grid := tview.NewGrid(). SetRows(1). SetColumns(1). SetBorders(false). AddItem(newPrimitive("X"), 0, 0, 1, 1, 0, 0, false) if err := tview.NewApplication().SetRoot(grid, true).EnableMouse(true).Run(); err != nil { panic(err) } } ``` `X` is always placed in a bottom-right corner. This looks something like: ``` +---------+ | | | | | X| +---------+ ``` Do I misunderstood grig logic as I'm kinda expecting `X` to be in a top-left corner like: ``` +---------+ |X | | | | | +---------+ ```
kerem closed this issue 2026-03-04 01:07:07 +03:00
Author
Owner

@rivo commented on GitHub (Apr 4, 2024):

To be honest, I have no idea why there was code which would align the last grid item to the bottom right corner. I wrote this 5 years ago and don't remember why.

I removed it with the latest commit while hoping I haven't broken any situation where it actually made sense.

<!-- gh-comment-id:2037638622 --> @rivo commented on GitHub (Apr 4, 2024): To be honest, I have no idea why there was code which would align the last grid item to the bottom right corner. I wrote this 5 years ago and don't remember why. I removed it with the latest commit while hoping I haven't broken any situation where it actually made sense.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#699
No description provided.