Closed atzannes closed 4 years ago
I have a few thoughts on this. First, the SingleLineTextBox
is one of the original Cells and we haven't done a lot of refactoring on it at all (yet). This also means that a full on spec was never described, although just by the given interface, constructor, and how it gets used I think I can answer most of your questions inline.
The second thing to know is that some larger structural issues that I'm working on will (should?) help alleviate some of the problems you are experiencing (more on that in a sec).
Generally, I believe the goal for SingleLineTextBox
is to have something that behaves almost exactly like a text input field in html. These inputs usually have three kinds of "events" associated with them:
Event | Explanation |
---|---|
input |
Triggered each time a key is pressed |
change |
Triggered only on enter/return key OR when field loses focus (tab elsewhere, etc) |
blur |
Triggered when the field loses focus |
We should decide which one of these events the box should use for "updating" associated Slot data on the Cells backend. For the moment, we are using change
.
I don't understand what the optional argument pattern
I believe this is a 1:1 argument for the equivalent attribute value for HTML input elements. It allows you to set some kind of regex that will prevent certain strings from being inputted into the resulting input field. See this MDN post for more information. That said -- do we really need this ability?
the SLTB does not display the contents of its Slot. Initially or after updating (hitting enter) the SLTB is empty. After editing text in the SLTB and hitting enter, the cursor goes away: I have to use the mouse to click on the SLTB to reactivate the cursor.
This is part of a deeper rendering problem. When the change
event happens, it refreshes not the Subscribed part of things but the parent of Subscribed, thus re-rendering the SingleLineTextBox itself. As a result, the field will lose focus and will not refresh the contents of the Slot.
I am currently working on a different rendering pattern per this conversation between @braxtonmckee and I. I'll keep this issue in mind once I've (hopefully) come up with a working solution.
There is, maybe, one issue I can fix: I should be able to have the refreshed input field force-show the contents of the Slot as its default value. I'll see if I can do that right now and push to your example branch.
@atzannes Check out this commit for a fix to the one issue I mentioned at the end of the previous comment.
That's cool and it works well with the text box demo, but it breaks with the ModalWithUpdateField. There, you get "Some Text" as the initial value of the SLTB not just the first time you open the modal, but also after you have changed the text in the Slot. A fix I came up with is here, but I don't know anything about how subscribed cells are supposed to re-evaluate themselves, so I might be going about it completely wrong.
@atzannes Yeah I have made some progress in the meantime, but there are deeper structural issues that I'm still working out with Subscribeds -- so no solution just yet. I'll keep you posted
It's exciting seeing the Cells infrastructure taking shape and becoming more stable :+1:
By the way, I tried my change on a large Cells page I'm modifying and it completely breaks the whole thing, so as I suspected, it's not the right way to go about it.
@atzannes Check out the latest eric-issue-68
commit. I think I have something that works. I wrote a bunch of tests for nested Subscribeds (on the JS side) and they seem to be working. I think SLTB, the Modal version, and (most importantly for this Subscribed stuff) the nested ResizablePanels with toggle button (called resizable_panel.ResizePanelWithButtons
) are all working. I have really tried to screw up the latter by using random combinations of toggle and everything seems to work.
If these things seem ok to you, I can move towards drafting a PR.
@braxtonmckee You might be interested in this too, as it is really about #68. The implementation details are not what we discussed in that issue for technical reasons, which I can document
Hm, I still have the unwanted behavior with the ModalWithUpdateField:
@atzannes Yes, I see. I'm pretty convinced that this has more to do with the specific SLTB implementation at this point than it does with the wider Subscription issues I was working on (thank god), so I'll work something out and get back to you
@atzannes I think this was fixed in #86, which was merged, and so should be working on dev
. If it works for you I think we can go ahead and close this issue.
Yes, looks good :+1:
Perhaps I don't understand how to use this Cell, but I thought SingleLineTextBox behaves unexpectedly. Perhaps @braxtonmckee can give his view as well.
This branch has an example usage for SingleLineTextBox (SLTB) with a Card that displays the contents of the Slot associated with the SLTB. It also has an attempt at introducing a filtering mechanism on the CellsDemo page for easily finding a cells demo of interest.
Unexpected Behaviors
Finally, I don't understand what the optional argument
pattern
in the SLTB constructor does. SLTB seems to be the only cell that has it, and I didn't see any places it's used as an example. Perhaps some documentation would help.