• LaurentDelcambre
  • NEWBIE
  • 20 Points
  • Member since 2014
  • Architect
  • LDCC Ltd

  • Chatter
    Feed
  • 0
    Best Answers
  • 5
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 5
    Replies
Hi,

How should we test that an element received focus.
In the js controller we are testing we used:
const button  = this.template.queryselector('xxx');
button.focus()

We know this works because it been tested through the UI ie. the focus box shows around the button.

I have tried a few things in Jest not nothign seems to work:

- Use jest-dom:
 

expect(button).toHaveFocus()


But only the top parent is returned by toHaveFocus().

I tested it in the smallest example possible and it just doesn't work.
- Use document.activeElement
that returns :
 

HTMLBridgeElement [HTMLElement] {}

I don't even understand what this could be, and Google doesn't seem to know either.
My gut feeling tells me that LockerService is preventing the use of document.activeElement, which is used under the hood  by jest-dom toHaveFocus().
But in the end I don't know how to test focus at all
Any idea?
Hi,

We used to be able to do this in Aura:
String labelName = 'mylabel';
$A.getReference("$Label.c."+ labelName);



$A is not accessible in LWC

Following the documentation I can only see a way to get access to Label's value through import.
As far as I know import don't work dynamically. You can only write an import if you know the name of the label.

I was hoping for a solution involving Apex and/or SOQL but could not find anything.

Any idea?
 
Hi,

I set up a CMS connection in my Community.
I used these settings:
CMS Source: Drupal
Connection type public:
Server URL: https://drupdemoeight8wnpr4ekpl.devcloud.acquia-sites.com

JSON:
Content list: 
- Name: List
- Path: content/rest?_format=json
- Node Path: nothing

When using the component CMS Connect JSON with the default values I see: "The server returned code HTTP 0"

I can confirm that my Rest service is well configures by testing it with Postman or even directly in the browser:
https://drupdemoeight8wnpr4ekpl.devcloud.acquia-sites.com/content/rest?_format=json

Any idea of what is wrong or how I could debug that?

Can we test the CMS connection?

Cheers,
Laurent


 
Hi all,

I'm trying to integrate a 3rd party Javascript library in my Lightning application.
This one if you are curious:
https://github.com/szimek/signature_pad

I can include the libray and initialize it with no problem but the problem arrises when you try to access the Javascript object through a different client side method.

EX:
({
  initSignature: function(component, event, helper) {
    console.log('init');

    var canvas = component.find("signCanvas").getElement();
    var signaturePad = new SignaturePad(canvas);
  },
	saveSignature: function(component, event, helper) {
    console.log('save');
    signaturePad.toDataURL()
	},
})

I need "signaturePad" to be accessible from all my Client-side controller methods.

Is there a way to have a globally accessible var?

Cheers,
Laurent