-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(REACH-519, REACH-527): Fix embed buttons (#590)
Prevent default action when embed button is clicked to avoid unintentional submit of parent form. Close buttons are now <button> and not <a> to improve SEO.
- Loading branch information
Showing
16 changed files
with
73 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ | |
color: #000; | ||
top: $top; | ||
right: $right; | ||
background: none; | ||
border: none; | ||
|
||
&:hover { | ||
opacity: 1; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import { createPopup } from '../factories/create-popup' | ||
import { POPUP_ATTRIBUTE } from '../constants' | ||
import { invokeWithoutDefault } from '../utils' | ||
|
||
import { initialize } from './initialize' | ||
|
||
export const initializePopups = (forceReload: boolean = false) => { | ||
initialize(POPUP_ATTRIBUTE, 'popup.css', forceReload, (formId, options, button) => { | ||
const { toggle } = createPopup(formId, options) | ||
button.onclick = toggle | ||
button.onclick = invokeWithoutDefault(toggle) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import { createSlider } from '../factories/create-slider' | ||
import { SLIDER_ATTRIBUTE } from '../constants' | ||
import { invokeWithoutDefault } from '../utils' | ||
|
||
import { initialize } from './initialize' | ||
|
||
export const initializeSliders = (forceReload: boolean = false) => { | ||
initialize(SLIDER_ATTRIBUTE, 'slider.css', forceReload, (formId, options, button) => { | ||
const { toggle } = createSlider(formId, options) | ||
button.onclick = toggle | ||
button.onclick = invokeWithoutDefault(toggle) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { invokeWithoutDefault } from './invoke-without-default' | ||
|
||
describe('#invokeWithoutDefault', () => { | ||
it('should invoke the function passed as argument but call preventDefault() on event', () => { | ||
const func = jest.fn() | ||
const event = { preventDefault: jest.fn() } as any | ||
const handler = invokeWithoutDefault(func) | ||
expect(func).not.toHaveBeenCalled() | ||
expect(event.preventDefault).not.toHaveBeenCalled() | ||
handler(event) | ||
expect(func).toHaveBeenCalled() | ||
expect(event.preventDefault).toHaveBeenCalled() | ||
}) | ||
|
||
it('should invoke the function passed as argument when called without event', () => { | ||
const func = jest.fn() | ||
const handler = invokeWithoutDefault(func) | ||
expect(func).not.toHaveBeenCalled() | ||
handler() | ||
expect(func).toHaveBeenCalled() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const invokeWithoutDefault = (func: () => void) => (event?: MouseEvent) => { | ||
event?.preventDefault() | ||
func() | ||
} |