Home

`LINQPad.Controls.DataListBox` hides content if it is the first thing added to a `DumpContainer`

Hi Joe :)

I'm back again with another super tiny issue I've stumbled across.

If I'm using a DumpContainer and UpdateContent with a DataListBox, each subsequent AppendContent gets eaten by the DataListBox rather than appended to the container.

It looks like in the HTML generated that the items added end up emitting in the datalist element associated with the DataListBox.

If DumpContainer.ClearContent() is called, and then the DataListBox added via AppendContent(), the issue doesn't occur. As well, the issue doesn't occur if something else is set as the container's content first.

Here's a screenshot of the issue. Only FailCase is not behaving as it should, where as the other 3 examples are correctly displaying "hello world":

And as usual, here's the repro code:

void Main()
{
    FailCase();
    ClearBeforeAppend();
    UpdateStringThenAppendDataListBox();
    TextBoxInsteadOfDataListBox();
}

void FailCase()
{
    DumpContainer dc = new();
    dc.UpdateContent(new DataListBox());
    dc.AppendContent("hello world");
    dc.Dump(nameof(FailCase));
    //dc.Content.GetType().GetMethod("GetContent")?.Invoke(dc.Content, null).Dump($"{nameof(FailCase)} Contents");
}

void ClearBeforeAppend()
{
    DumpContainer dc = new();
    dc.ClearContent();
    dc.AppendContent(new DataListBox());
    dc.AppendContent("hello world");
    dc.Dump(nameof(ClearBeforeAppend));
    //dc.Content.GetType().GetMethod("GetContent")?.Invoke(dc.Content, null).Dump($"{nameof(ClearBeforeAppend)} Contents");
}

void UpdateStringThenAppendDataListBox()
{
    DumpContainer dc = new();
    dc.UpdateContent("hello world");
    dc.AppendContent(new DataListBox());
    dc.Dump(nameof(UpdateStringThenAppendDataListBox));
    //dc.Content.GetType().GetMethod("GetContent")?.Invoke(dc.Content, null).Dump($"{nameof(UpdateStringThenAppendDataListBox)} Contents");
}

void TextBoxInsteadOfDataListBox()
{
    DumpContainer dc = new();
    dc.UpdateContent(new TextBox());
    dc.AppendContent("hello world");
    dc.Dump(nameof(TextBoxInsteadOfDataListBox));
    //dc.Content.GetType().GetMethod("GetContent")?.Invoke(dc.Content, null).Dump($"{nameof(TextBoxInsteadOfDataListBox)} Contents");
}

Cheers and hope you're well!

Comments

Sign In or Register to comment.