Code Monkey home page Code Monkey logo

Comments (8)

msaraiva avatar msaraiva commented on July 30, 2024 1

Hi @miguel-s!

Ideally, it shouldn't be necessary to pass it manually. The :__surface__ assign belongs to the private API. I'll create a test for this case so we can work on a proper solution.

Cheers.

from surface.

cadebward avatar cadebward commented on July 30, 2024

To clarify, this isn't blocking. Since the target changes in live view, you can work around this easily by creating a handle_event/3 in your modal component, and then targeting that component with a phx-click & phx-target on your button.

def handle_event("open", _data, socket) do
  {:noreply, assign(socket, open: true)}
end

from surface.

msaraiva avatar msaraiva commented on July 30, 2024

Hi @cadebward!

I was able to reproduce it. I'll push a fix for it soon.

Thanks for the report.

from surface.

msaraiva avatar msaraiva commented on July 30, 2024

@cadebward!

Actually I can't reproduce it :)

I found another edge case which is when the content of the dialog is empty but that raise another error. What changes should I make in the Dialog demo to raise the same error?

Is the demo not working at all in your tests? Does it work if you use this branch? https://github.com/msaraiva/surface/tree/ms-context-api

from surface.

msaraiva avatar msaraiva commented on July 30, 2024

Just to clarify, the PR is ready to go. As soon as I update the examples, I'll merge it.

In case you're using contexts, you need to adjust your code to the new API, i.e, you need to declare when using context.

Example for the Form component:

  ...
  property change, :event

  context set form, :form

  def init_context(assigns) do
    opts = [phx_change: assigns.change.name, autocomplete: assigns.autocomplete]
    form = form_for(assigns.for, "#", opts)
    {:ok, form: form}
  end
...

Example for the Field component:

  context set field, :atom, scope: :only_children
  context get form, from: Form

  def init_context(assigns) do
    {:ok, field: String.to_atom(assigns.field)}
  end

and finally, Textinput:

  context get form, from: Form
  context get field, from: Field

Note: end_context/1 is no longer required.

from surface.

cadebward avatar cadebward commented on July 30, 2024

Hmm... I wonder if my problem was that I had a custom update/2 function? I'll go ahead and close this since it was easy to work around and you aren't able to reproduce. Thanks for the update.

from surface.

miguel-s avatar miguel-s commented on July 30, 2024

Hi @msaraiva @cadebward!

I'm running into the same issue with send_update. It seems to only occur when I use a custom update/2 function, just as @cadebward suspected.

I found workaround by passing the :__surface__ assign in the send_update function.

from surface.

miguel-s avatar miguel-s commented on July 30, 2024

Hi @msaraiva!

Just want to confirm that #114 fixed this issue for me.
I was still using the v0.1.0-alpha.2 release, but recently upgraded to the master branch.

Thanks!

from surface.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.