Comments (10)
@dkniffin I'm afraid I haven't been able to replicate this at all
Because I can't replicate it and the demo seems to be working for you I think I'm going to close this down for now - if you see the issue repeated elsewhere or manage to get any other clues about what could be causing it please feel free to reopen and I'll try to look into it again.
I'm sorry this is getting in the way of you using Lookbook and hope you find a solution đ
from lookbook.
Hey @dkniffin, sorry to hear you are running into a problem here and apologies for the slow reply. You shouldn't need to include any JS or configure anything, this should just all work out of the box.
Could you let me know what browser you are using so I can look into it a bit more when I have a chance?
And do you think you could just confirm whether or not the tabs on the demo site (http://demo.lookbook.build/lookbook/inspect/elements/avatar/default) are working for you or not?
from lookbook.
Brave v1.50.114, Chromium: 112.0.5615.49
on MacOS 12.5.1
And yes, the tabs on the demo site are working. So likely something specific to my app or configuration
from lookbook.
@allmarkedup I'm starting to dig into this a bit more. Comparing the attributes on my app vs the demo, I see @click.prevent
isn't set on my tabs. From what I can tell, that gets set here. Any idea why it wouldn't be set for me?
from lookbook.
Dug in some more. I forked the repo and pointed to it locally, and put some debuggers in. This is happening for me with all buttons. I'm testing with the refresh-preview-button, which includes @click.stop
.
When execution gets to this line, html_attrs
is correct and includes @click.stop
.
From there, it goes to here and html_attrs
still has @click.stop
.
But when it gets to here, @html_attrs
no longer has @click.stop
from lookbook.
I found the issue. It's something custom to my app. We've overridden our ViewComponent::Base
to set an attribute for debugging, that will tell us which component is outputting each part of the DOM:
module ViewComponentDebugOutput
def render_in(*args)
value = super
return value unless Rails.env.development? && ENV["VIEW_COMPONENT_DEBUG_ATTRIBUTES"] == "true"
begin
fragment = Nokogiri::HTML.fragment(value)
# We can't do anything useful if the ViewComponent doesn't have a single root element
return value if fragment.children.length != 1
root = fragment.children[0]
root["data-vc-debug-name"] = self.class.name
value.html_safe? ? root.to_html.html_safe : root.to_html
rescue => e
value
end
end
end
ActiveSupport.on_load(:view_component) do
ViewComponent::Base.prepend(ViewComponentDebugOutput)
end
Something about this causes the issue. When I comment all that out, the issue is solved.
I'll figure out what to do from here
from lookbook.
Hey @dkniffin, thanks for digging into this and apologies for not replying sooner.
So based on your info above, I believe what is happening here is that Nokogiri is not liking the non-standard HTML attributes names that AlpineJS uses (at least in shorthand format) and is stripping those out when re-assembling the DOM in your render_in
method above.
And example of one of these attributes is the @click
attribute on the tab component:
This is obviously a bit of a niche issue but as it may still affect others I'm going to swap the shorthand Alpine HTML attributes for their more 'standard' long form versions - I suspect that Nokogiri will tolerate those a bit better and there is now downside really (apart from a little more verbosity).
I'm going to reopen this issue now and will hopefully get a fix out in the next release unless I run into any unforseen issues.
from lookbook.
@dkniffin I've just opened a PR (#467) that removes replaces the shorthand attribute names. If you have a spare few minutes could you try pulling in Lookbook from that branch and seeing if that fixes the issue for you, even with your debug fragment in place? Thank you!
from lookbook.
@allmarkedup Yes, I can test it. But FYI, I have since deleted that debugging fragment in favor of the built-in annotate_rendered_view_with_filenames Rails config.
Edit: Confirmed, that PR fixed it â
from lookbook.
@dkniffin thanks for the confirmation! Much appreciated. The fix has gone out in the latest 2.0.3 release so I'm going to close this down now.
from lookbook.
Related Issues (20)
- Why does the preview filter ignore the path/folder structure? HOT 4
- Add the ability to hide a nested within a group. HOT 3
- Cannot choose display options in an embedded preview HOT 4
- Support better errors / web console instead of rescuing errors in Lookbook HOT 2
- undefined method `strftime' for nil:NilClass with nil datetime HOT 1
- Hidden scenarios within groups are not accessible via their URL
- Swap the order of Previews and Pages sections HOT 4
- Ability to search within pages section HOT 3
- X-Frame-Options always set to deny HOT 8
- Can't draw templates that require instance variables HOT 5
- Lookbook overrides ViewComponent `show_previews` config depending on load order HOT 3
- ActionView::Template::Error occurs when trying to render a template file with a partial HOT 5
- FEA: Support for Mailer Previews HOT 1
- Support configurable frame ancestors for embeds HOT 2
- Documentation request: mention support for Phlex in the README HOT 5
- Previews not rendering nested components HOT 2
- Better integration with Phlex HOT 1
- Version requirement for listen gem is not specified, and wrong version error is suppressed HOT 1
- Syntax error reporting in Lookbook HOT 2
- Sharing View Component Previews Across Multiple Projects Without Duplicating Files
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
đ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google â¤ī¸ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lookbook.