Tuesday, December 19, 2017

Shortcut key for Lightning Component Button.

Scenario: Use the previously posted lightning component (UpdateStudent) [Post Subject : Crate a lightning component to update record.].
Now suppose we want to create/develop shortcut keys for "Save" [Alt + s] and "Cancel" [Alt + c] button for out component.


Solution: To develop the shortcut key in lightning component use "accesskey" key-word under your "lightning:button" component. So, for the above scenario use the below syntax under your "lightning:button" component,

  • For Save : accesskey="s"
  • For Cancel : accesskey="c"
And the button code base is look like this for our UpdateStudent component,

                <lightning:button aura:id="cancelId"
                                  label="Cancel"
                                  variant="brand"
                                  onclick="{!c.doCancel}"
                                  accesskey="c"/>
               
                <lightning:button aura:id="saveId"
                                  label="Save"
                                  variant="neutral"
                                  onclick="{!c.doSave}"
                                  accesskey="s"/>

So, update the component's buttons part with above code base and use "Alt + s" and "Alt + c" for save and cancel operation respectively.

LWC to LWC Communication using Lightning Messaging Service (Part - 2)

In my previous post ( previous post link ) we have learn how to create a Lightning Messaging Service with 6 steps and today we will use the ...