And so the first thing I did is I thought, you know, I should actually file an issue. So the next day I went ahead and opened an issue on the Remix repo and said, hey, here this is a bug, you know, like, be, be cool to fix that someday. And I left it at that.
But a couple of weeks went by and I thought, you know, it would actually be cool to fix this bug. So I want to give back a little bit, it's not, it seems like an easy bug, how hard could it be, right. It ended up being a little bit involved, right.
So as it turns out, you know, browsers do know how to construct a form data object from a form, but they don't know how to specify the submitter in the right position. So to work around this, I thought, OK, one option would be I could actually implement form data construction myself. So I looked at the spec and kind of copy pasted the text of it and then implemented it, which is like 300 lines of code, which is kind of a bit much. So then the second approach I went with is like maybe I can do those hidden input shenanigans, but do that remix. And that was a lot less code. But again, it's a little janky. I don't know if it's the best approach, but I feel a little better now because actually six months ago, Sebastian added basically the same thing to React proper with the form action stuff they added. So not terrible. I'm in good company, but I wasn't altogether completely happy with these approaches, but I wanted to get a discussion going with the Remix team to see if we could fix it.
And while I did this research, I realized that smart browser people had been looking into this before. They realized there was actually a missing feature in the browser, in the spec, as far as how this could work because like I said, forums, browsers know how to submit them and know how to properly put the submit button in there. But when you're constructing a forum, a forum dataset from a forum, the form data object didn't know how to do that. There wasn't a way to specify the submitter. And so they kicked around some ideas as far as how that might look, what's the best interface, but nothing really had happened since 2019. And so I thought, okay, that's good to know. Maybe someday I can use that. That'll be cool. But in the meantime, I had another problem with my PR.
So I made these changes, but the Remix team was in the midst of refactoring a whole bunch of stuff and kind of graduating this functionality from Remix into React Router, which meant I couldn't make those changes there, and they'd have to actually land in React Router at some future date when that was done. So I kind of left it in a holding pattern, and a couple of months went by and finally the changes landed in React Router, and so I was able to make those PRs over there instead of in Remix. But then I had a new problem, right? So React Router does its testing with Jest and JS DOM, and there were some missing features, missing functionality in JS DOM. So if you haven't used JS DOM, it's a really great library. Powers Jest, React testing library. It's primarily authored and maintained by Dominic, super smart guy, and I think of him as a JS DOM, so now you can too.
Comments